48#include "llvm/ADT/SmallString.h"
49#include "llvm/ADT/StringExtras.h"
50#include "llvm/TargetParser/Triple.h"
55#include <unordered_map>
62 Decl *Group[2] = { OwnedType, Ptr };
73 TypeNameValidatorCCC(
bool AllowInvalid,
bool WantClass =
false,
74 bool AllowTemplates =
false,
75 bool AllowNonTemplates =
true)
76 : AllowInvalidDecl(AllowInvalid), WantClassName(WantClass),
77 AllowTemplates(AllowTemplates), AllowNonTemplates(AllowNonTemplates) {
78 WantExpressionKeywords =
false;
79 WantCXXNamedCasts =
false;
80 WantRemainingKeywords =
false;
85 if (!AllowInvalidDecl && ND->isInvalidDecl())
89 return AllowTemplates;
95 if (AllowNonTemplates)
100 if (AllowTemplates) {
101 auto *RD = dyn_cast<CXXRecordDecl>(ND);
102 if (!RD || !RD->isInjectedClassName())
105 return RD->getDescribedClassTemplate() ||
112 return !WantClassName && candidate.
isKeyword();
115 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
116 return std::make_unique<TypeNameValidatorCCC>(*
this);
120 bool AllowInvalidDecl;
123 bool AllowNonTemplates;
135 case tok::kw___int64:
136 case tok::kw___int128:
138 case tok::kw_unsigned:
146 case tok::kw__Float16:
147 case tok::kw___float128:
148 case tok::kw___ibm128:
149 case tok::kw_wchar_t:
151#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case tok::kw___##Trait:
152#include "clang/Basic/TransformTypeTraits.def"
153 case tok::kw___auto_type:
156 case tok::annot_typename:
157 case tok::kw_char16_t:
158 case tok::kw_char32_t:
160 case tok::annot_decltype:
161 case tok::kw_decltype:
164 case tok::kw_char8_t:
175enum class UnqualifiedTypeNameLookupResult {
186static UnqualifiedTypeNameLookupResult
191 return UnqualifiedTypeNameLookupResult::NotFound;
193 UnqualifiedTypeNameLookupResult FoundTypeDecl =
194 UnqualifiedTypeNameLookupResult::NotFound;
197 if (
auto *BaseTT =
Base.getType()->getAs<TagType>())
198 BaseRD = BaseTT->getAsCXXRecordDecl();
199 else if (
auto *TST =
Base.getType()->getAs<TemplateSpecializationType>()) {
202 if (!TST || !TST->isDependentType())
204 auto *TD = TST->getTemplateName().getAsTemplateDecl();
207 if (
auto *BasePrimaryTemplate =
208 dyn_cast_or_null<CXXRecordDecl>(TD->getTemplatedDecl())) {
210 BaseRD = BasePrimaryTemplate;
211 else if (
auto *CTD = dyn_cast<ClassTemplateDecl>(TD)) {
213 CTD->findPartialSpecialization(
Base.getType()))
221 if (!isa<TypeDecl>(ND))
222 return UnqualifiedTypeNameLookupResult::FoundNonType;
223 FoundTypeDecl = UnqualifiedTypeNameLookupResult::FoundType;
225 if (FoundTypeDecl == UnqualifiedTypeNameLookupResult::NotFound) {
227 case UnqualifiedTypeNameLookupResult::FoundNonType:
228 return UnqualifiedTypeNameLookupResult::FoundNonType;
229 case UnqualifiedTypeNameLookupResult::FoundType:
230 FoundTypeDecl = UnqualifiedTypeNameLookupResult::FoundType;
232 case UnqualifiedTypeNameLookupResult::NotFound:
239 return FoundTypeDecl;
247 UnqualifiedTypeNameLookupResult FoundTypeDecl =
248 UnqualifiedTypeNameLookupResult::NotFound;
250 DC && FoundTypeDecl == UnqualifiedTypeNameLookupResult::NotFound;
254 RD = dyn_cast<CXXRecordDecl>(DC);
258 if (FoundTypeDecl != UnqualifiedTypeNameLookupResult::FoundType)
264 S.
Diag(NameLoc, diag::ext_found_in_dependent_base) << &II;
285 bool WantNontrivialTypeSourceInfo =
true) {
286 switch (T->getTypeClass()) {
287 case Type::DeducedTemplateSpecialization:
289 case Type::InjectedClassName:
292 case Type::UnresolvedUsing:
297 case Type::ObjCInterface:
298 case Type::ObjCTypeParam:
299 case Type::TemplateTypeParm:
302 llvm_unreachable(
"Unexpected Type Class");
310 if (!WantNontrivialTypeSourceInfo)
331 bool HasTrailingDot,
ParsedType ObjectTypePtr,
332 bool IsCtorOrDtorName,
333 bool WantNontrivialTypeSourceInfo,
334 bool IsClassTemplateDeductionContext,
338 bool AllowDeducedTemplate = IsClassTemplateDeductionContext &&
340 !isClassName && !HasTrailingDot;
365 !isClassName && !IsCtorOrDtorName)
367 bool IsImplicitTypename = !isClassName && !IsCtorOrDtorName;
368 if (IsImplicitTypename) {
371 Diag(QualifiedLoc, diag::warn_cxx17_compat_implicit_typename);
373 Diag(QualifiedLoc, diag::ext_implicit_typename)
380 if (WantNontrivialTypeSourceInfo)
412 if (ObjectTypePtr &&
Result.empty()) {
436 switch (
Result.getResultKind()) {
440 TypeNameValidatorCCC CCC(
true, isClassName,
441 AllowDeducedTemplate);
446 bool MemberOfUnknownSpecialization;
455 if (Correction && (NNS || NewII != &II) &&
461 Template, MemberOfUnknownSpecialization))) {
463 isClassName, HasTrailingDot, ObjectTypePtr,
465 WantNontrivialTypeSourceInfo,
466 IsClassTemplateDeductionContext);
469 PDiag(diag::err_unknown_type_or_class_name_suggest)
470 <<
Result.getLookupName() << isClassName);
473 *CorrectedII = NewII;
482 Result.suppressDiagnostics();
492 Result.suppressDiagnostics();
498 Res != ResEnd; ++Res) {
500 if (isa<TypeDecl, ObjCInterfaceDecl, UnresolvedUsingIfExistsDecl>(
507 FoundUsingShadow = dyn_cast<UsingShadowDecl>(*Res);
519 Result.suppressDiagnostics();
530 IIDecl =
Result.getFoundDecl();
531 FoundUsingShadow = dyn_cast<UsingShadowDecl>(*
Result.begin());
535 assert(IIDecl &&
"Didn't find decl");
538 if (
TypeDecl *TD = dyn_cast<TypeDecl>(IIDecl)) {
542 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(LookupCtx);
543 auto *FoundRD = dyn_cast<CXXRecordDecl>(TD);
544 if (!isClassName && !IsCtorOrDtorName && LookupRD && FoundRD &&
545 FoundRD->isInjectedClassName() &&
547 Diag(NameLoc, diag::err_out_of_line_qualified_id_type_names_constructor)
558 FoundUsingShadow =
nullptr;
559 }
else if (
auto *UD = dyn_cast<UnresolvedUsingIfExistsDecl>(IIDecl)) {
563 }
else if (AllowDeducedTemplate) {
565 assert(!FoundUsingShadow || FoundUsingShadow->
getTargetDecl() == TD);
571 FoundUsingShadow =
nullptr;
577 Result.suppressDiagnostics();
581 if (FoundUsingShadow)
584 return buildNamedType(*
this, SS, T, NameLoc, WantNontrivialTypeSourceInfo);
592 auto *ND = dyn_cast<NamespaceDecl>(DC);
593 if (ND && !ND->isInline() && !ND->isAnonymousNamespace())
595 else if (
auto *RD = dyn_cast<CXXRecordDecl>(DC))
597 RD->getTypeForDecl());
598 else if (isa<TranslationUnitDecl>(DC))
601 llvm_unreachable(
"something isn't in TU scope?");
612 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DC))
613 if (MD->getParent()->hasAnyDependentBases())
621 bool IsTemplateTypeArg) {
622 assert(
getLangOpts().MSVCCompat &&
"shouldn't be called in non-MSVC mode");
625 if (IsTemplateTypeArg &&
getCurScope()->isTemplateParamScope()) {
634 Diag(NameLoc, diag::ext_ms_delayed_template_argument) << &II;
640 RD->getTypeForDecl());
644 Diag(NameLoc, diag::ext_undeclared_unqual_id_with_dependent_base) << &II
679 switch (TD->getTagKind()) {
716 return S->isFunctionPrototypeScope();
726 bool IsTemplateName) {
731 SuggestedType =
nullptr;
735 TypeNameValidatorCCC CCC(
false,
false,
742 bool CanRecover = !IsTemplateName;
743 if (Corrected.isKeyword()) {
746 PDiag(IsTemplateName ? diag::err_no_template_suggest
747 : diag::err_unknown_typename_suggest)
749 II = Corrected.getCorrectionAsIdentifierInfo();
752 if (!SS || !SS->
isSet()) {
754 PDiag(IsTemplateName ? diag::err_no_template_suggest
755 : diag::err_unknown_typename_suggest)
758 std::string CorrectedStr(Corrected.getAsString(
getLangOpts()));
759 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
760 II->
getName().equals(CorrectedStr);
763 ? diag::err_no_member_template_suggest
764 : diag::err_unknown_nested_typename_suggest)
765 << II << DC << DroppedSpecifier << SS->
getRange(),
768 llvm_unreachable(
"could not have corrected a typo here");
775 if (Corrected.getCorrectionSpecifier())
780 getTypeName(*Corrected.getCorrectionAsIdentifierInfo(), IILoc, S,
781 tmpSS.
isSet() ? &tmpSS : SS,
false,
false,
nullptr,
791 Name.setIdentifier(II, IILoc);
794 bool MemberOfUnknownSpecialization;
796 Name,
nullptr,
true, TemplateResult,
807 Diag(IILoc, IsTemplateName ? diag::err_no_template
808 : diag::err_unknown_typename)
811 Diag(IILoc, IsTemplateName ? diag::err_no_member_template
812 : diag::err_typename_nested_not_found)
818 unsigned DiagID = diag::err_typename_missing;
820 DiagID = diag::ext_typename_missing;
827 *SS, *II, IILoc).
get();
830 "Invalid scope specifier has already been diagnosed");
838 NextToken.
is(tok::less);
841 if (isa<TypeDecl>(*I) || isa<ObjCInterfaceDecl>(*I))
844 if (CheckTemplate && isa<TemplateDecl>(*I))
858 StringRef FixItTagName;
859 switch (Tag->getTagKind()) {
861 FixItTagName =
"class ";
865 FixItTagName =
"enum ";
869 FixItTagName =
"struct ";
873 FixItTagName =
"__interface ";
877 FixItTagName =
"union ";
881 StringRef TagName = FixItTagName.drop_back();
882 SemaRef.
Diag(NameLoc, diag::err_use_of_tag_name_without_tag)
883 << Name << TagName << SemaRef.
getLangOpts().CPlusPlus
888 SemaRef.
Diag((*I)->getLocation(), diag::note_decl_hiding_tag_type)
903 const Token &NextToken,
908 assert(NextToken.
isNot(tok::coloncolon) &&
909 "parse nested name specifiers before calling ClassifyName");
949 bool SecondTry =
false;
950 bool IsFilteredTemplateName =
false;
953 switch (
Result.getResultKind()) {
957 if (SS.
isEmpty() && NextToken.
is(tok::l_paren)) {
1003 if (!SecondTry && CCC) {
1008 unsigned UnqualifiedDiag = diag::err_undeclared_var_use_suggest;
1009 unsigned QualifiedDiag = diag::err_no_member_suggest;
1012 NamedDecl *UnderlyingFirstDecl = Corrected.getCorrectionDecl();
1014 UnderlyingFirstDecl && isa<TemplateDecl>(UnderlyingFirstDecl)) {
1015 UnqualifiedDiag = diag::err_no_template_suggest;
1016 QualifiedDiag = diag::err_no_member_template_suggest;
1017 }
else if (UnderlyingFirstDecl &&
1018 (isa<TypeDecl>(UnderlyingFirstDecl) ||
1019 isa<ObjCInterfaceDecl>(UnderlyingFirstDecl) ||
1020 isa<ObjCCompatibleAliasDecl>(UnderlyingFirstDecl))) {
1021 UnqualifiedDiag = diag::err_unknown_typename_suggest;
1022 QualifiedDiag = diag::err_unknown_nested_typename_suggest;
1028 std::string CorrectedStr(Corrected.getAsString(
getLangOpts()));
1029 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
1030 Name->getName().equals(CorrectedStr);
1033 << DroppedSpecifier << SS.
getRange());
1037 Name = Corrected.getCorrectionAsIdentifierInfo();
1040 if (Corrected.isKeyword())
1046 Result.setLookupName(Corrected.getCorrection());
1068 Result.suppressDiagnostics();
1110 if (!
Result.isAmbiguous()) {
1111 IsFilteredTemplateName =
true;
1121 (IsFilteredTemplateName ||
1137 if (!IsFilteredTemplateName)
1140 bool IsFunctionTemplate;
1144 IsFunctionTemplate =
true;
1147 }
else if (!
Result.empty()) {
1155 dyn_cast<UsingShadowDecl>(*
Result.begin());
1156 assert(!FoundUsingShadow ||
1157 TD == cast<TemplateDecl>(FoundUsingShadow->
getTargetDecl()));
1167 IsFunctionTemplate =
true;
1171 if (IsFunctionTemplate) {
1175 Result.suppressDiagnostics();
1186 if (
const auto *USD = dyn_cast<UsingShadowDecl>(Found))
1202 dyn_cast<ObjCCompatibleAliasDecl>(
FirstDecl))
1203 Class = Alias->getClassInterface();
1209 if (NextToken.
is(tok::period)) {
1212 Result.suppressDiagnostics();
1224 if (
auto *EmptyD = dyn_cast<UnresolvedUsingIfExistsDecl>(
FirstDecl)) {
1237 bool NextIsOp = NextToken.
isOneOf(tok::amp, tok::star);
1238 if ((NextToken.
is(tok::identifier) ||
1240 FirstDecl->getUnderlyingDecl()->isFunctionOrFunctionTemplate())) &&
1252 if (
Result.isSingleResult() && !ADL &&
1257 Result.suppressDiagnostics();
1260 Result.getLookupNameInfo(), ADL,
Result.isOverloadedResult(),
1277 bool IsAddressOfOperand) {
1280 NameInfo, IsAddressOfOperand,
1287 const Token &NextToken) {
1305 if ((*ULE->decls_begin())->isCXXClassMember()) {
1307 SS.
Adopt(ULE->getQualifierLoc());
1312 Result.setNamingClass(ULE->getNamingClass());
1313 for (
auto I = ULE->decls_begin(), E = ULE->decls_end(); I != E; ++I)
1314 Result.addDecl(*I, I.getAccess());
1327 auto *TD = Name.getAsTemplateDecl();
1330 if (isa<ClassTemplateDecl>(TD))
1332 if (isa<FunctionTemplateDecl>(TD))
1334 if (isa<VarTemplateDecl>(TD))
1336 if (isa<TypeAliasTemplateDecl>(TD))
1338 if (isa<TemplateTemplateParmDecl>(TD))
1340 if (isa<ConceptDecl>(TD))
1347 "The next DeclContext should be lexically contained in the current one.");
1353 assert(
CurContext &&
"DeclContext imbalance!");
1356 assert(
CurContext &&
"Popped translation unit!");
1366 assert(
CurContext &&
"skipping definition of undefined tag");
1397 assert(!S->getEntity() &&
"scope already has entity");
1400 Scope *Ancestor = S->getParent();
1408 if (S->getParent()->isTemplateParamScope()) {
1416 assert(S->getEntity() ==
CurContext &&
"Context imbalance!");
1420 Scope *Ancestor = S->getParent();
1429 assert(S->isTemplateParamScope() &&
1430 "expected to be initializing a template parameter scope");
1454 for (; S && S->isTemplateParamScope(); S = S->getParent(), --ScopeDepth) {
1458 cast<Decl>(DC)->getDescribedTemplateParams()) {
1459 unsigned DCDepth = TPL->getDepth() + 1;
1460 if (DCDepth > ScopeDepth)
1462 if (ScopeDepth == DCDepth)
1467 S->setLookupEntity(SearchDCAfterScope);
1481 "The next DeclContext should be lexically contained in the current one.");
1485 for (
unsigned P = 0, NumParams = FD->
getNumParams();
P < NumParams; ++
P) {
1488 if (Param->getIdentifier()) {
1498 assert(
CurContext &&
"DeclContext imbalance!");
1500 assert(
CurContext &&
"Popped translation unit!");
1529 return ND->
hasAttr<OverloadableAttr>();
1532 return Previous.getFoundDecl()->hasAttr<OverloadableAttr>();
1542 while (S->getEntity() && S->getEntity()->isTransparentContext())
1557 if (isa<FunctionDecl>(D) &&
1558 cast<FunctionDecl>(D)->isFunctionTemplateSpecialization())
1564 for (; I != IEnd; ++I) {
1576 if (isa<LabelDecl>(D) && !cast<LabelDecl>(D)->isGnuLocal()) {
1583 if (!S->isDeclScope(*I))
1597 bool AllowInlineNamespace)
const {
1605 if (ScopeDC->getPrimaryContext() == TargetDC)
1607 }
while ((S = S->getParent()));
1619 bool ConsiderLinkage,
1620 bool AllowInlineNamespace) {
1681 if (NewIsModuleInterface || OldIsModuleInterface) {
1687 << NewIsModuleInterface
1689 << OldIsModuleInterface
1720 if (!IsNewExported && !IsOldExported)
1726 assert(IsNewExported);
1734 Diag(New->
getLocation(), diag::err_redeclaration_non_exported) << New << S;
1770 "New and Old are not the same definition, we should diagnostic it "
1771 "immediately instead of checking it.");
1774 "We shouldn't see unreachable definitions here.");
1822 return OldM == NewM;
1859 return CD->isCopyConstructor();
1878 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(DC)){
1879 if (!RD->hasNameForLinkage())
1908 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
1914 FD->getMemberSpecializationInfo() && !FD->isOutOfLine())
1917 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
1922 if (FD->isInlined() && !
isMainFileLoc(*
this, FD->getLocation()))
1926 if (FD->doesThisDeclarationHaveABody() &&
1929 }
else if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1939 if (VD->isStaticDataMember() &&
1942 if (VD->isStaticDataMember() &&
1944 VD->getMemberSpecializationInfo() && !VD->isOutOfLine())
1947 if (VD->isInline() && !
isMainFileLoc(*
this, VD->getLocation()))
1956 return mightHaveNonExternalLinkage(D);
1963 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
1969 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1983 if (
auto *DD = dyn_cast<DecompositionDecl>(D)) {
1987 for (
auto *BD : DD->bindings())
1988 if (BD->isReferenced())
1996 if (D->
hasAttr<UnusedAttr>() || D->
hasAttr<ObjCPreciseLifetimeAttr>() ||
2000 if (isa<LabelDecl>(D))
2006 if (
const auto *R = dyn_cast<CXXRecordDecl>(D->
getDeclContext()))
2009 WithinFunction || (R->isLocalClass() && !R->isDependentType());
2010 if (!WithinFunction)
2013 if (isa<TypedefNameDecl>(D))
2017 if (!isa<VarDecl>(D) || isa<ParmVarDecl>(D) || isa<ImplicitParamDecl>(D))
2021 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
2023 const Expr *Init = VD->getInit();
2024 if (
const auto *Cleanups = dyn_cast_or_null<ExprWithCleanups>(Init))
2025 Init = Cleanups->getSubExpr();
2027 const auto *Ty = VD->getType().getTypePtr();
2032 if (TT->getDecl()->hasAttr<UnusedAttr>())
2038 if (
const auto *MTE = dyn_cast_or_null<MaterializeTemporaryExpr>(Init)) {
2039 if (MTE->getExtendingDecl()) {
2040 Ty = VD->getType().getNonReferenceType().getTypePtr();
2041 Init = MTE->getSubExpr()->IgnoreImplicitAsWritten();
2047 if (Ty->isIncompleteType() || Ty->isDependentType())
2052 Ty = Ty->getBaseElementTypeUnsafe();
2054 if (
const TagType *TT = Ty->getAs<TagType>()) {
2055 const TagDecl *Tag = TT->getDecl();
2056 if (Tag->hasAttr<UnusedAttr>())
2059 if (
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Tag)) {
2060 if (!RD->hasTrivialDestructor() && !RD->hasAttr<WarnUnusedAttr>())
2065 dyn_cast<CXXConstructExpr>(Init);
2068 if (!CD->
isTrivial() && !RD->hasAttr<WarnUnusedAttr>() &&
2069 (VD->getInit()->isValueDependent() || !VD->evaluateValue()))
2075 if (Init->isTypeDependent()) {
2077 if (!Ctor->isTrivial())
2083 if (isa<CXXUnresolvedConstructExpr>(Init))
2097 if (isa<LabelDecl>(D)) {
2118 for (
auto *TmpD : D->
decls()) {
2119 if (
const auto *T = dyn_cast<TypedefNameDecl>(TmpD))
2121 else if(
const auto *R = dyn_cast<RecordDecl>(TmpD))
2137 if (
auto *TD = dyn_cast<TypedefNameDecl>(D)) {
2148 if (isa<VarDecl>(D) && cast<VarDecl>(D)->isExceptionVariable())
2149 DiagID = diag::warn_unused_exception_param;
2150 else if (isa<LabelDecl>(D))
2151 DiagID = diag::warn_unused_label;
2153 DiagID = diag::warn_unused_variable;
2169 if (Ty->isReferenceType() || Ty->isDependentType())
2172 if (
const TagType *TT = Ty->getAs<TagType>()) {
2173 const TagDecl *Tag = TT->getDecl();
2174 if (Tag->hasAttr<UnusedAttr>())
2178 if (
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Tag)) {
2179 if (!RD->hasAttr<WarnUnusedAttr>())
2187 if (VD->
hasAttr<BlocksAttr>() && Ty->isObjCObjectPointerType())
2193 if (VD->
hasAttr<ObjCPreciseLifetimeAttr>() && Ty->isObjCObjectPointerType())
2200 assert(iter->getSecond() >= 0 &&
2201 "Found a negative number of references to a VarDecl");
2202 if (iter->getSecond() != 0)
2204 unsigned DiagID =
isa<ParmVarDecl>(VD) ? diag::warn_unused_but_set_parameter
2205 : diag::warn_unused_but_set_variable;
2215 bool Diagnose =
false;
2219 Diagnose = L->
getStmt() ==
nullptr;
2228 if (S->decl_empty())
return;
2230 "Scope shouldn't contain decls!");
2237 std::optional<SourceLocation> PreviousDeclLoc;
2242 DeclDiags.push_back(LocAndDiag{Loc, std::nullopt, std::move(PD)});
2247 DeclDiags.push_back(LocAndDiag{Loc, PreviousDeclLoc, std::move(PD)});
2250 for (
auto *TmpD : S->decls()) {
2251 assert(TmpD &&
"This decl didn't get pushed??");
2253 assert(isa<NamedDecl>(TmpD) &&
"Decl isn't NamedDecl?");
2257 if (!S->hasUnrecoverableErrorOccurred()) {
2259 if (
const auto *RD = dyn_cast<RecordDecl>(D))
2261 if (
VarDecl *VD = dyn_cast<VarDecl>(D)) {
2270 if (
LabelDecl *LD = dyn_cast<LabelDecl>(D))
2276 auto ShadowI = ShadowingDecls.find(D);
2277 if (ShadowI != ShadowingDecls.end()) {
2278 if (
const auto *FD = dyn_cast<FieldDecl>(ShadowI->second)) {
2279 addDiagWithPrev(D->
getLocation(), FD->getLocation(),
2280 PDiag(diag::warn_ctor_parm_shadows_field)
2281 << D << FD << FD->getParent());
2283 ShadowingDecls.erase(ShadowI);
2287 llvm::sort(DeclDiags,
2288 [](
const LocAndDiag &LHS,
const LocAndDiag &RHS) ->
bool {
2293 return LHS.Loc.getRawEncoding() < RHS.Loc.getRawEncoding();
2295 for (
const LocAndDiag &D : DeclDiags) {
2297 if (D.PreviousDeclLoc)
2298 Diag(*D.PreviousDeclLoc, diag::note_previous_declaration);
2317 bool DoTypoCorrection) {
2322 if (!IDecl && DoTypoCorrection) {
2366 (S->getEntity() && S->getEntity()->isTransparentContext()) ||
2384 return "ucontext.h";
2386 llvm_unreachable(
"unhandled error kind");
2397 Parent->addDecl(CLinkageDecl);
2412 for (
unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
2415 FT->getParamType(i),
nullptr,
SC_None,
nullptr);
2417 Params.push_back(parm);
2419 New->setParams(Params);
2431 Scope *S,
bool ForRedeclaration,
2438 if (!ForRedeclaration)
2450 Diag(Loc, diag::warn_implicit_decl_no_jmp_buf)
2457 Diag(Loc, diag::warn_implicit_decl_requires_sysheader)
2463 if (!ForRedeclaration &&
2466 Diag(Loc,
LangOpts.C99 ? diag::ext_implicit_lib_function_decl_c99
2467 : diag::ext_implicit_lib_function_decl)
2470 Diag(Loc, diag::note_include_header_or_declare)
2507 while (Filter.hasNext()) {
2516 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
2518 Decl->getUnderlyingType()))
2523 if (OldTD->getAnonDeclWithTypedefName(
true) &&
2524 Decl->getAnonDeclWithTypedefName())
2537 OldType = OldTypedef->getUnderlyingType();
2545 Diag(New->
getLocation(), diag::err_redefinition_variably_modified_typedef)
2553 if (OldType != NewType &&
2559 << Kind << NewType << OldType;
2583 switch (TypeID->getLength()) {
2587 if (!TypeID->isStr(
"id"))
2590 if (!T->isPointerType())
2592 if (!T->isVoidPointerType()) {
2603 if (!TypeID->isStr(
"Class"))
2610 if (!TypeID->isStr(
"SEL"))
2637 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
2638 auto *OldTag = OldTD->getAnonDeclWithTypedefName(
true);
2641 if (OldTag && NewTag &&
2642 OldTag->getCanonicalDecl() != NewTag->getCanonicalDecl() &&
2647 if (OldTD->isModed())
2649 OldTD->getUnderlyingType());
2658 if (isa<EnumDecl>(NewTag)) {
2660 for (
auto *D : NewTag->decls()) {
2665 ED->getLexicalDeclContext()->removeDecl(ED);
2715 if (!isa<TypedefNameDecl>(Old))
2747 const OwnershipAttr *OA = dyn_cast<OwnershipAttr>(A);
2748 const AnnotateAttr *Ann = dyn_cast<AnnotateAttr>(A);
2749 for (
const auto *i : D->
attrs())
2750 if (i->getKind() == A->
getKind()) {
2752 if (Ann->getAnnotation() == cast<AnnotateAttr>(i)->getAnnotation())
2757 if (OA && isa<OwnershipAttr>(i))
2766 if (
VarDecl *VD = dyn_cast<VarDecl>(D))
2767 return VD->isThisDeclarationADefinition();
2768 if (
TagDecl *TD = dyn_cast<TagDecl>(D))
2769 return TD->isCompleteDefinition() || TD->isBeingDefined();
2780 AlignedAttr *OldAlignasAttr =
nullptr;
2781 AlignedAttr *OldStrictestAlignAttr =
nullptr;
2782 unsigned OldAlign = 0;
2790 if (I->isAlignmentDependent())
2796 unsigned Align = I->getAlignment(S.
Context);
2797 if (Align > OldAlign) {
2799 OldStrictestAlignAttr = I;
2804 AlignedAttr *NewAlignasAttr =
nullptr;
2805 unsigned NewAlign = 0;
2807 if (I->isAlignmentDependent())
2813 unsigned Align = I->getAlignment(S.
Context);
2814 if (Align > NewAlign)
2818 if (OldAlignasAttr && NewAlignasAttr && OldAlign != NewAlign) {
2826 if (OldAlign == 0 || NewAlign == 0) {
2828 if (
ValueDecl *VD = dyn_cast<ValueDecl>(New))
2839 if (OldAlign != NewAlign) {
2840 S.
Diag(NewAlignasAttr->getLocation(), diag::err_alignas_mismatch)
2843 S.
Diag(OldAlignasAttr->getLocation(), diag::note_previous_declaration);
2858 S.
Diag(OldAlignasAttr->getLocation(), diag::note_alignas_on_declaration)
2862 bool AnyAdded =
false;
2865 if (OldAlign > NewAlign) {
2866 AlignedAttr *Clone = OldStrictestAlignAttr->clone(S.
Context);
2867 Clone->setInherited(
true);
2873 if (OldAlignasAttr && !NewAlignasAttr &&
2874 !(AnyAdded && OldStrictestAlignAttr->isAlignas())) {
2875 AlignedAttr *Clone = OldAlignasAttr->clone(S.
Context);
2876 Clone->setInherited(
true);
2884#define WANT_DECL_MERGE_LOGIC
2885#include "clang/Sema/AttrParsedAttrImpl.inc"
2886#undef WANT_DECL_MERGE_LOGIC
2893 if (!DiagnoseMutualExclusions(S, D,
Attr))
2904 if (
const auto *AA = dyn_cast<AvailabilityAttr>(
Attr))
2906 D, *AA, AA->getPlatform(), AA->
isImplicit(), AA->getIntroduced(),
2907 AA->getDeprecated(), AA->getObsoleted(), AA->getUnavailable(),
2908 AA->getMessage(), AA->getStrict(), AA->getReplacement(), AMK,
2910 else if (
const auto *VA = dyn_cast<VisibilityAttr>(
Attr))
2912 else if (
const auto *VA = dyn_cast<TypeVisibilityAttr>(
Attr))
2914 else if (
const auto *ImportA = dyn_cast<DLLImportAttr>(
Attr))
2916 else if (
const auto *ExportA = dyn_cast<DLLExportAttr>(
Attr))
2918 else if (
const auto *EA = dyn_cast<ErrorAttr>(
Attr))
2920 else if (
const auto *FA = dyn_cast<FormatAttr>(
Attr))
2921 NewAttr = S.
mergeFormatAttr(D, *FA, FA->getType(), FA->getFormatIdx(),
2923 else if (
const auto *SA = dyn_cast<SectionAttr>(
Attr))
2925 else if (
const auto *CSA = dyn_cast<CodeSegAttr>(
Attr))
2927 else if (
const auto *IA = dyn_cast<MSInheritanceAttr>(
Attr))
2929 IA->getInheritanceModel());
2930 else if (
const auto *AA = dyn_cast<AlwaysInlineAttr>(
Attr))
2933 else if (S.
getLangOpts().CUDA && isa<FunctionDecl>(D) &&
2934 (isa<CUDAHostAttr>(
Attr) || isa<CUDADeviceAttr>(
Attr) ||
2935 isa<CUDAGlobalAttr>(
Attr))) {
2939 }
else if (
const auto *MA = dyn_cast<MinSizeAttr>(
Attr))
2941 else if (
const auto *SNA = dyn_cast<SwiftNameAttr>(
Attr))
2943 else if (
const auto *OA = dyn_cast<OptimizeNoneAttr>(
Attr))
2945 else if (
const auto *InternalLinkageA = dyn_cast<InternalLinkageAttr>(
Attr))
2947 else if (isa<AlignedAttr>(
Attr))
2951 else if ((isa<DeprecatedAttr>(
Attr) || isa<UnavailableAttr>(
Attr)) &&
2956 else if (
const auto *UA = dyn_cast<UuidAttr>(
Attr))
2957 NewAttr = S.
mergeUuidAttr(D, *UA, UA->getGuid(), UA->getGuidDecl());
2958 else if (
const auto *IMA = dyn_cast<WebAssemblyImportModuleAttr>(
Attr))
2960 else if (
const auto *INA = dyn_cast<WebAssemblyImportNameAttr>(
Attr))
2962 else if (
const auto *TCBA = dyn_cast<EnforceTCBAttr>(
Attr))
2964 else if (
const auto *TCBLA = dyn_cast<EnforceTCBLeafAttr>(
Attr))
2966 else if (
const auto *BTFA = dyn_cast<BTFDeclTagAttr>(
Attr))
2968 else if (
const auto *NT = dyn_cast<HLSLNumThreadsAttr>(
Attr))
2971 else if (
const auto *SA = dyn_cast<HLSLShaderAttr>(
Attr))
2979 if (isa<MSInheritanceAttr>(NewAttr))
2988 if (
const TagDecl *TD = dyn_cast<TagDecl>(D))
2989 return TD->getDefinition();
2990 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
2996 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
2998 if (FD->isDefined(Def,
true))
3005 for (
const auto *Attribute : D->
attrs())
3006 if (Attribute->getKind() == Kind)
3018 if (!Def || Def == New)
3022 for (
unsigned I = 0, E = NewAttributes.size(); I != E;) {
3023 const Attr *NewAttribute = NewAttributes[I];
3025 if (isa<AliasAttr>(NewAttribute) || isa<IFuncAttr>(NewAttribute)) {
3032 NewAttributes.erase(NewAttributes.begin() + I);
3040 ? diag::err_alias_after_tentative
3041 : diag::err_redefinition;
3043 if (
Diag == diag::err_redefinition)
3053 if (
const VarDecl *VD = dyn_cast<VarDecl>(Def)) {
3066 if (isa<C11NoReturnAttr>(NewAttribute)) {
3070 }
else if (isa<UuidAttr>(NewAttribute)) {
3074 }
else if (
const AlignedAttr *AA = dyn_cast<AlignedAttr>(NewAttribute)) {
3075 if (AA->isAlignas()) {
3086 S.
Diag(NewAttribute->
getLocation(), diag::note_alignas_on_declaration)
3088 NewAttributes.erase(NewAttributes.begin() + I);
3092 }
else if (isa<LoaderUninitializedAttr>(NewAttribute)) {
3098 diag::err_loader_uninitialized_redeclaration);
3100 NewAttributes.erase(NewAttributes.begin() + I);
3104 }
else if (isa<SelectAnyAttr>(NewAttribute) &&
3105 cast<VarDecl>(New)->isInline() &&
3106 !cast<VarDecl>(New)->isInlineSpecified()) {
3113 }
else if (isa<OMPDeclareVariantAttr>(NewAttribute)) {
3121 diag::warn_attribute_precede_definition);
3123 NewAttributes.erase(NewAttributes.begin() + I);
3129 const ConstInitAttr *CIAttr,
3130 bool AttrBeforeInit) {
3137 std::string SuitableSpelling;
3139 SuitableSpelling = std::string(
3141 if (SuitableSpelling.empty() && S.
getLangOpts().CPlusPlus11)
3143 InsertLoc, {tok::l_square, tok::l_square,
3144 S.PP.getIdentifierInfo(
"clang"), tok::coloncolon,
3145 S.PP.getIdentifierInfo(
"require_constant_initialization"),
3146 tok::r_square, tok::r_square}));
3147 if (SuitableSpelling.empty())
3149 InsertLoc, {tok::kw___attribute, tok::l_paren, tok::r_paren,
3150 S.PP.getIdentifierInfo(
"require_constant_initialization"),
3151 tok::r_paren, tok::r_paren}));
3152 if (SuitableSpelling.empty() && S.
getLangOpts().CPlusPlus20)
3153 SuitableSpelling =
"constinit";
3154 if (SuitableSpelling.empty() && S.
getLangOpts().CPlusPlus11)
3155 SuitableSpelling =
"[[clang::require_constant_initialization]]";
3156 if (SuitableSpelling.empty())
3157 SuitableSpelling =
"__attribute__((require_constant_initialization))";
3158 SuitableSpelling +=
" ";
3160 if (AttrBeforeInit) {
3163 assert(CIAttr->isConstinit() &&
"should not diagnose this for attribute");
3166 S.
Diag(CIAttr->getLocation(), diag::note_constinit_specified_here);
3170 S.
Diag(CIAttr->getLocation(),
3171 CIAttr->isConstinit() ? diag::err_constinit_added_too_late
3172 : diag::warn_require_const_init_added_too_late)
3175 << CIAttr->isConstinit()
3184 UsedAttr *NewAttr = OldAttr->clone(
Context);
3185 NewAttr->setInherited(
true);
3189 RetainAttr *NewAttr = OldAttr->clone(
Context);
3190 NewAttr->setInherited(
true);
3200 const auto *OldConstInit = Old->
getAttr<ConstInitAttr>();
3201 const auto *NewConstInit = New->
getAttr<ConstInitAttr>();
3202 if (
bool(OldConstInit) !=
bool(NewConstInit)) {
3210 (NewVD->hasInit() || NewVD->isThisDeclarationADefinition()))
3213 if (InitDecl == NewVD) {
3217 if (OldConstInit && OldConstInit->isConstinit())
3220 }
else if (NewConstInit) {
3224 if (InitDecl && InitDecl != NewVD) {
3227 NewVD->dropAttr<ConstInitAttr>();
3235 if (AsmLabelAttr *NewA = New->
getAttr<AsmLabelAttr>()) {
3236 if (AsmLabelAttr *OldA = Old->
getAttr<AsmLabelAttr>()) {
3237 if (!OldA->isEquivalent(NewA)) {
3240 Diag(OldA->getLocation(), diag::note_previous_declaration);
3242 }
else if (Old->
isUsed()) {
3251 if (
const auto *NewAbiTagAttr = New->
getAttr<AbiTagAttr>()) {
3252 if (
const auto *OldAbiTagAttr = Old->
getAttr<AbiTagAttr>()) {
3253 for (
const auto &NewTag : NewAbiTagAttr->tags()) {
3254 if (!llvm::is_contained(OldAbiTagAttr->tags(), NewTag)) {
3255 Diag(NewAbiTagAttr->getLocation(),
3256 diag::err_new_abi_tag_on_redeclaration)
3258 Diag(OldAbiTagAttr->getLocation(), diag::note_previous_declaration);
3262 Diag(NewAbiTagAttr->getLocation(), diag::err_abi_tag_on_redeclaration);
3268 if (New->
hasAttr<SectionAttr>() && !Old->
hasAttr<SectionAttr>()) {
3269 if (
auto *VD = dyn_cast<VarDecl>(New)) {
3271 Diag(New->
getLocation(), diag::warn_attribute_section_on_redeclaration);
3278 const auto *NewCSA = New->
getAttr<CodeSegAttr>();
3279 if (NewCSA && !Old->
hasAttr<CodeSegAttr>() &&
3280 !NewCSA->isImplicit() && isa<CXXMethodDecl>(New)) {
3298 if (isa<DeprecatedAttr>(I) ||
3299 isa<UnavailableAttr>(I) ||
3300 isa<AvailabilityAttr>(I)) {
3315 if (isa<UsedAttr>(I) || isa<RetainAttr>(I))
3337 const CarriesDependencyAttr *CDA = newDecl->
getAttr<CarriesDependencyAttr>();
3338 if (CDA && !oldDecl->
hasAttr<CarriesDependencyAttr>()) {
3339 S.
Diag(CDA->getLocation(),
3340 diag::err_carries_dependency_missing_on_first_decl) << 1;
3348 diag::note_carries_dependency_missing_first_decl) << 1;
3354 bool foundAny = newDecl->
hasAttrs();
3376 auto NoSizeInfo = [&Ctx](
QualType Ty) {
3377 if (Ty->isIncompleteArrayType() || Ty->isPointerType())
3385 if (NoSizeInfo(Old) && NoSizeInfo(New))
3417 if (*Oldnullability != *Newnullability) {
3418 S.
Diag(NewParam->
getLocation(), diag::warn_mismatched_nullability_attr)
3432 AttributedType::getNullabilityAttrKind(*Oldnullability),
3437 const auto *OldParamDT = dyn_cast<DecayedType>(OldParam->
getType());
3438 const auto *NewParamDT = dyn_cast<DecayedType>(NewParam->
getType());
3439 if (OldParamDT && NewParamDT &&
3440 OldParamDT->getPointeeType() == NewParamDT->getPointeeType()) {
3441 QualType OldParamOT = OldParamDT->getOriginalType();
3442 QualType NewParamOT = NewParamDT->getOriginalType();
3445 << NewParam << NewParamOT;
3456struct GNUCompatibleParamWarning {
3466template <
typename T>
3467static std::pair<diag::kind, SourceLocation>
3471 if (Old->isThisDeclarationADefinition())
3472 PrevDiag = diag::note_previous_definition;
3473 else if (Old->isImplicit()) {
3474 PrevDiag = diag::note_previous_implicit_declaration;
3475 if (
const auto *FD = dyn_cast<FunctionDecl>(Old)) {
3476 if (FD->getBuiltinID())
3477 PrevDiag = diag::note_previous_builtin_declaration;
3480 OldLocation = New->getLocation();
3482 PrevDiag = diag::note_previous_declaration;
3483 return std::make_pair(PrevDiag, OldLocation);
3491 return ((FD->
hasAttr<GNUInlineAttr>() || LangOpts.GNUInline) &&
3492 !LangOpts.CPlusPlus &&
3498 const AttributedType *AT = T->getAs<AttributedType>();
3499 while (AT && !AT->isCallingConv())
3500 AT = AT->getModifiedType()->getAs<AttributedType>();
3504template <
typename T>
3518template<
typename T>
static bool isExternC(T *D) {
return D->isExternC(); }
3525template<
typename ExpectedDecl>
3547 !Old->getDeclContext()->getRedeclContext()->Equals(
3548 New->getDeclContext()->getRedeclContext()) &&
3553 S.
Diag(New->getLocation(), diag::err_using_decl_conflict_reverse);
3566 const auto *AttrA = A->
getAttr<PassObjectSizeAttr>();
3567 const auto *AttrB = B->
getAttr<PassObjectSizeAttr>();
3570 return AttrA && AttrB && AttrA->getType() == AttrB->getType() &&
3571 AttrA->isDynamic() == AttrB->isDynamic();
3597 if (NamedDC->Equals(SemaDC))
3600 assert((NamedDC->InEnclosingNamespaceSetOf(SemaDC) ||
3602 "unexpected context for redeclaration");
3613 if (
auto *FD = dyn_cast<FunctionDecl>(NewD))
3614 FixSemaDC(FD->getDescribedFunctionTemplate());
3615 else if (
auto *VD = dyn_cast<VarDecl>(NewD))
3616 FixSemaDC(VD->getDescribedVarTemplate());
3631 bool MergeTypeWithOld,
bool NewDeclIsDefn) {
3638 Diag(Shadow->getTargetDecl()->getLocation(),
3639 diag::note_using_decl_target);
3640 Diag(Shadow->getIntroducer()->getLocation(), diag::note_using_decl)
3685 std::tie(PrevDiag, OldLocation) =
3692 if (!isa<CXXMethodDecl>(New) && !isa<CXXMethodDecl>(Old) &&
3699 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3702 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3707 if (
const auto *ILA = New->
getAttr<InternalLinkageAttr>())
3708 if (!Old->
hasAttr<InternalLinkageAttr>()) {
3712 New->
dropAttr<InternalLinkageAttr>();
3715 if (
auto *EA = New->
getAttr<ErrorAttr>()) {
3716 if (!Old->
hasAttr<ErrorAttr>()) {
3717 Diag(EA->getLocation(), diag::err_attribute_missing_on_first_decl) << EA;
3727 bool OldOvl = Old->
hasAttr<OverloadableAttr>();
3738 const Decl *DiagOld = Old;
3740 auto OldIter = llvm::find_if(Old->
redecls(), [](
const Decl *D) {
3741 const auto *A = D->getAttr<OverloadableAttr>();
3742 return A && !A->isImplicit();
3746 DiagOld = OldIter == Old->
redecls_end() ? nullptr : *OldIter;
3751 diag::note_attribute_overloadable_prev_overload)
3780 bool RequiresAdjustment =
false;
3782 if (OldTypeInfo.
getCC() != NewTypeInfo.
getCC()) {
3788 if (!NewCCExplicit) {
3792 RequiresAdjustment =
true;
3804 RequiresAdjustment =
true;
3811 << (!FirstCCExplicit ?
"" :
3815 Diag(
First->getLocation(), diag::note_previous_declaration);
3823 RequiresAdjustment =
true;
3833 Diag(OldLocation, diag::note_previous_declaration);
3838 RequiresAdjustment =
true;
3845 <<
"'ns_returns_retained'";
3846 Diag(OldLocation, diag::note_previous_declaration);
3851 RequiresAdjustment =
true;
3857 AnyX86NoCallerSavedRegistersAttr *
Attr =
3858 New->
getAttr<AnyX86NoCallerSavedRegistersAttr>();
3860 Diag(OldLocation, diag::note_previous_declaration);
3865 RequiresAdjustment =
true;
3868 if (RequiresAdjustment) {
3878 !New->
hasAttr<GNUInlineAttr>() &&
3887 if (New->
hasAttr<GNUInlineAttr>() &&
3898 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3927 OldDeclaredReturnType)) {
3935 Diag(New->
getLocation(), diag::err_member_def_does_not_match_ret_type)
3940 Diag(OldLocation, PrevDiag) << Old << Old->
getType()
3950 if (OldReturnType != NewReturnType) {
3954 if (OldAT && OldAT->isDeduced()) {
3955 QualType DT = OldAT->getDeducedType();
3966 const CXXMethodDecl *OldMethod = dyn_cast<CXXMethodDecl>(Old);
3968 if (OldMethod && NewMethod) {
3975 bool IsClassScopeExplicitSpecialization =
3981 !IsClassScopeExplicitSpecialization) {
3987 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3997 if (isa<CXXConstructorDecl>(OldMethod))
3998 NewDiag = diag::err_constructor_redeclared;
3999 else if (isa<CXXDestructorDecl>(NewMethod))
4000 NewDiag = diag::err_destructor_redeclared;
4001 else if (isa<CXXConversionDecl>(NewMethod))
4002 NewDiag = diag::err_conv_function_redeclared;
4004 NewDiag = diag::err_member_redeclared;
4008 Diag(New->
getLocation(), diag::err_member_redeclared_in_instantiation)
4011 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
4024 diag::err_definition_of_implicitly_declared_member)
4030 diag::err_definition_of_explicitly_defaulted_member)
4040 if (
const auto *NRA = New->
getAttr<CXX11NoReturnAttr>())
4041 if (!Old->
hasAttr<CXX11NoReturnAttr>()) {
4042 Diag(NRA->getLocation(), diag::err_attribute_missing_on_first_decl)
4051 const CarriesDependencyAttr *CDA = New->
getAttr<CarriesDependencyAttr>();
4052 if (CDA && !Old->
hasAttr<CarriesDependencyAttr>()) {
4053 Diag(CDA->getLocation(),
4054 diag::err_carries_dependency_missing_on_first_decl) << 0;
4056 diag::note_carries_dependency_missing_first_decl) << 0;
4065 QualType OldQTypeForComparison = OldQType;
4070 OldQTypeForComparison =
QualType(OldTypeForComparison, 0);
4085 Diag(OldLocation, PrevDiag);
4087 Diag(New->
getLocation(), diag::err_different_language_linkage) << New;
4088 Diag(OldLocation, PrevDiag);
4159 bool IsWithoutProtoADef =
false, IsWithProtoADef =
false;
4160 if (WithoutProto == New)
4161 IsWithoutProtoADef = NewDeclIsDefn;
4163 IsWithProtoADef = NewDeclIsDefn;
4165 diag::warn_non_prototype_changes_behavior)
4166 << IsWithoutProtoADef << (WithoutProto->
getNumParams() ? 0 : 1)
4167 << (WithoutProto == Old) << IsWithProtoADef;
4177 !IsWithoutProtoADef)
4187 if (MergeTypeWithOld && isa<FunctionNoProtoType>(NewFuncType) &&
4188 (OldProto = dyn_cast<FunctionProtoType>(OldFuncType))) {
4191 assert(!OldProto->hasExceptionSpec() &&
"Exception spec in C");
4193 OldProto->getParamTypes(),
4194 OldProto->getExtProtoInfo());
4200 for (
const auto &ParamType : OldProto->param_types()) {
4203 ParamType,
nullptr,
SC_None,
nullptr);
4204 Param->setScopeInfo(0, Params.size());
4205 Param->setImplicit();
4206 Params.push_back(Param);
4209 New->setParams(Params);
4245 NewProto->getReturnType());
4246 bool LooseCompatible = !MergedReturn.
isNull();
4248 LooseCompatible && Idx != End; ++Idx) {
4252 NewProto->getParamType(Idx))) {
4253 ArgTypes.push_back(NewParm->
getType());
4257 GNUCompatibleParamWarning Warn = { OldParm, NewParm,
4258 NewProto->getParamType(Idx) };
4259 Warnings.push_back(Warn);
4260 ArgTypes.push_back(NewParm->
getType());
4262 LooseCompatible =
false;
4265 if (LooseCompatible) {
4266 for (
unsigned Warn = 0; Warn < Warnings.size(); ++Warn) {
4267 Diag(Warnings[Warn].NewParm->getLocation(),
4268 diag::ext_param_promoted_not_compatible_with_prototype)
4269 << Warnings[Warn].PromotedType
4270 << Warnings[Warn].OldParm->getType();
4271 if (Warnings[Warn].OldParm->getLocation().isValid())
4272 Diag(Warnings[Warn].OldParm->getLocation(),
4273 diag::note_previous_declaration);
4276 if (MergeTypeWithOld)
4296 Diag(OldLocation, diag::note_previous_builtin_declaration)
4301 PrevDiag = diag::note_previous_builtin_declaration;
4305 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
4319 Scope *S,
bool MergeTypeWithOld) {
4334 for (
unsigned i = 0, e = New->
getNumParams(); i != e; ++i) {
4348 if (!Merged.isNull() && MergeTypeWithOld)
4371 ni != ne && oi != oe; ++ni, ++oi)
4381 ? diag::err_redefinition_different_type
4382 : diag::err_redeclaration_different_type)
4387 std::tie(PrevDiag, OldLocation)
4389 S.
Diag(OldLocation, PrevDiag) << Old << Old->
getType();
4401 bool MergeTypeWithOld) {
4429 QualType PrevVDTy = PrevVD->getType();
4483 if (MergeTypeWithOld)
4529 if (!shouldLinkPossiblyHiddenDecl(
Previous, New))
4539 OldTemplate = dyn_cast<VarTemplateDecl>(
Previous.getFoundDecl());
4543 dyn_cast<UsingShadowDecl>(
Previous.getRepresentativeDecl()))
4547 Old = dyn_cast<VarDecl>(
Previous.getFoundDecl());
4550 dyn_cast<UsingShadowDecl>(
Previous.getRepresentativeDecl()))
4588 if (New->
hasAttr<WeakImportAttr>() &&
4590 !Old->
hasAttr<WeakImportAttr>()) {
4597 if (
const auto *ILA = New->
getAttr<InternalLinkageAttr>())
4598 if (!Old->
hasAttr<InternalLinkageAttr>()) {
4602 New->
dropAttr<InternalLinkageAttr>();
4607 if (MostRecent != Old) {
4620 std::tie(PrevDiag, OldLocation) =
4630 Diag(OldLocation, PrevDiag);
4634 Diag(OldLocation, PrevDiag);
4653 Diag(OldLocation, PrevDiag);
4661 Diag(OldLocation, PrevDiag);
4667 Diag(OldLocation, PrevDiag);
4683 Diag(OldLocation, PrevDiag);
4693 Diag(Def->getLocation(), diag::note_previous_definition);
4707 Diag(OldLocation, PrevDiag);
4710 Diag(OldLocation, PrevDiag);
4718 Diag(OldLocation, PrevDiag);
4728 diag::warn_deprecated_redundant_constexpr_static_def);
4737 Diag(New->
getLocation(), diag::err_different_language_linkage) << New;
4738 Diag(OldLocation, PrevDiag);
4768 StringRef HdrFilename =
4771 auto noteFromModuleOrInclude = [&](
Module *Mod,
4777 if (IncLoc.isValid()) {
4779 Diag(IncLoc, diag::note_redefinition_modules_same_file)
4785 Diag(IncLoc, diag::note_redefinition_include_same_file)
4786 << HdrFilename.str();
4796 if (FNew == FOld && FNewDecLoc.second == FOldDecLoc.second) {
4804 if (FOld && !HSI.isFileMultipleIncludeGuarded(FOld))
4822 isa<VarTemplateSpecializationDecl>(New) ||
4861 ? S->getMSCurManglingNumber()
4862 : S->getMSLastManglingNumber();
4869 if (isa<CXXRecordDecl>(Tag->getParent())) {
4872 if (!Tag->getName().empty() || Tag->getTypedefNameForAnonDecl())
4884 Decl *ManglingContextDecl;
4885 std::tie(MCtx, ManglingContextDecl) =
4895struct NonCLikeKind {
4907 explicit operator bool() {
return Kind !=
None; }
4915 return {NonCLikeKind::Invalid, {}};
4922 return {NonCLikeKind::BaseClass,
4934 if (
auto *FD = dyn_cast<FieldDecl>(D)) {
4935 if (FD->hasInClassInitializer()) {
4936 auto *Init = FD->getInClassInitializer();
4937 return {NonCLikeKind::DefaultMemberInit,
4945 if (isa<FriendDecl>(D))
4950 if (isa<StaticAssertDecl>(D) || isa<IndirectFieldDecl>(D) ||
4953 auto *MemberRD = dyn_cast<CXXRecordDecl>(D);
4961 if (MemberRD->isLambda())
4962 return {NonCLikeKind::Lambda, MemberRD->getSourceRange()};
4966 if (MemberRD->isThisDeclarationADefinition()) {
4972 return {
Invalid ? NonCLikeKind::Invalid : NonCLikeKind::None, {}};
5002 const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(TagFromDeclSpec);
5006 if (NonCLike || ChangesLinkage) {
5007 if (NonCLike.Kind == NonCLikeKind::Invalid)
5010 unsigned DiagID = diag::ext_non_c_like_anon_struct_in_typedef;
5011 if (ChangesLinkage) {
5013 if (NonCLike.Kind == NonCLikeKind::None)
5014 DiagID = diag::err_typedef_changes_linkage;
5016 DiagID = diag::err_non_c_like_anon_struct_in_typedef;
5022 TextToInsert +=
' ';
5025 Diag(FixitLoc, DiagID)
5028 if (NonCLike.Kind != NonCLikeKind::None) {
5029 Diag(NonCLike.Range.
getBegin(), diag::note_non_c_like_anon_struct)
5030 << NonCLike.Kind - 1 << NonCLike.Range;
5033 << NewTD << isa<TypeAliasDecl>(NewTD);
5055 if (
const auto *ED = dyn_cast<EnumDecl>(DS.
getRepAsDecl())) {
5056 if (ED->isScopedUsingClassTag())
5063 llvm_unreachable(
"unexpected type specifier");
5073 bool IsExplicitInstantiation,
5075 Decl *TagD =
nullptr;
5090 if (isa<TagDecl>(TagD))
5093 Tag = CTD->getTemplatedDecl();
5098 Tag->setFreeStanding();
5099 if (Tag->isInvalidDecl())
5108 diag::err_typecheck_invalid_restrict_not_pointer_noarg)
5143 bool IsExplicitSpecialization =
5144 !TemplateParams.empty() && TemplateParams.back()->size() == 0;
5145 if (Tag && SS.
isNotEmpty() && !Tag->isCompleteDefinition() &&
5146 !IsExplicitInstantiation && !IsExplicitSpecialization &&
5147 !isa<ClassTemplatePartialSpecializationDecl>(Tag)) {
5156 Diag(SS.
getBeginLoc(), diag::err_standalone_class_nested_name_specifier)
5162 bool DeclaresAnything =
true;
5165 if (
RecordDecl *Record = dyn_cast_or_null<RecordDecl>(Tag)) {
5166 if (!Record->getDeclName() && Record->isCompleteDefinition() &&
5169 Record->getDeclContext()->isRecord()) {
5178 AnonRecord = Record;
5183 DeclaresAnything =
false;
5202 if ((Tag && Tag->getDeclName()) ||
5206 Record = dyn_cast<RecordDecl>(Tag);
5207 else if (
const RecordType *RT =
5209 Record = RT->getDecl();
5211 Record = UT->getDecl();
5219 DeclaresAnything =
false;
5231 if (
Enum->enumerator_begin() ==
Enum->enumerator_end() &&
5232 !
Enum->getIdentifier() && !
Enum->isInvalidDecl())
5233 DeclaresAnything =
false;
5241 DeclaresAnything =
false;
5245 Tag && Tag->getDeclContext()->isFunctionOrMethod())
5247 << Tag->getTagKind()
5260 if (!DeclaresAnything) {
5263 Diag(DS.
getBeginLoc(), (IsExplicitInstantiation || !TemplateParams.empty())
5264 ? diag::err_no_declarators
5265 : diag::ext_no_declarators)
5278 unsigned DiagID = diag::warn_standalone_specifier;
5280 DiagID = diag::ext_standalone_specifier;
5321 Diag(AL.getLoc(), AL.isRegularKeywordAttribute()
5322 ? diag::err_declspec_keyword_has_no_effect
5323 : diag::warn_declspec_attribute_ignored)
5326 Diag(AL.getLoc(), AL.isRegularKeywordAttribute()
5327 ? diag::err_declspec_keyword_has_no_effect
5328 : diag::warn_declspec_attribute_ignored)
5352 assert(PrevDecl &&
"Expected a non-null Decl");
5357 SemaRef.
Diag(NameLoc, diag::err_anonymous_record_member_redecl)
5359 SemaRef.
Diag(PrevDecl->
getLocation(), diag::note_previous_declaration);
5387 for (
auto *D : AnonRecord->
decls()) {
5388 if ((isa<FieldDecl>(D) || isa<IndirectFieldDecl>(D)) &&
5389 cast<NamedDecl>(D)->getDeclName()) {
5405 unsigned OldChainingSize = Chaining.size();
5407 Chaining.append(IF->chain_begin(), IF->chain_end());
5409 Chaining.push_back(VD);
5411 assert(Chaining.size() >= 2);
5414 for (
unsigned i = 0; i < Chaining.size(); i++)
5415 NamedChain[i] = Chaining[i];
5419 VD->
getType(), {NamedChain, Chaining.size()});
5431 Chaining.resize(OldChainingSize);
5446 "Parser allowed 'typedef' as storage class VarDecl.");
5447 switch (StorageClassSpec) {
5461 llvm_unreachable(
"unknown storage class specifier");
5465 assert(Record->hasInClassInitializer());
5467 for (
const auto *I : Record->decls()) {
5468 const auto *FD = dyn_cast<FieldDecl>(I);
5469 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(I))
5470 FD = IFD->getAnonField();
5471 if (FD && FD->hasInClassInitializer())
5472 return FD->getLocation();
5475 llvm_unreachable(
"couldn't find in-class initializer");
5480 if (!
Parent->isUnion() || !
Parent->hasInClassInitializer())
5483 S.
Diag(DefaultInitLoc, diag::err_multiple_mem_union_initialization);
5489 if (!
Parent->isUnion() || !
Parent->hasInClassInitializer())
5507 Diag(Record->getLocation(), diag::ext_anonymous_union);
5509 Diag(Record->getLocation(), diag::ext_gnu_anonymous_struct);
5511 Diag(Record->getLocation(), diag::ext_c11_anonymous_struct);
5517 const char *PrevSpec =
nullptr;
5518 if (Record->isUnion()) {
5528 !cast<NamespaceDecl>(OwnerScope)->isAnonymousNamespace()))) {
5529 Diag(Record->getLocation(), diag::err_anonymous_union_not_static)
5534 PrevSpec, DiagID, Policy);
5540 isa<RecordDecl>(Owner)) {
5542 diag::err_anonymous_union_with_storage_spec)
5556 << Record->isUnion() <<
"const"
5560 diag::ext_anonymous_struct_union_qualified)
5561 << Record->isUnion() <<
"volatile"
5565 diag::ext_anonymous_struct_union_qualified)
5566 << Record->isUnion() <<
"restrict"
5570 diag::ext_anonymous_struct_union_qualified)
5571 << Record->isUnion() <<
"_Atomic"
5575 diag::ext_anonymous_struct_union_qualified)
5576 << Record->isUnion() <<
"__unaligned"
5586 for (
auto *Mem : Record->decls()) {
5588 if (Mem->isInvalidDecl())
5591 if (
auto *FD = dyn_cast<FieldDecl>(Mem)) {
5595 assert(FD->getAccess() !=
AS_none);
5597 Diag(FD->getLocation(), diag::err_anonymous_record_nonpublic_member)
5598 << Record->isUnion() << (FD->getAccess() ==
AS_protected);
5609 }
else if (Mem->isImplicit()) {
5611 }
else if (isa<TagDecl>(Mem) && Mem->getDeclContext() != Record) {
5616 }
else if (
auto *MemRecord = dyn_cast<RecordDecl>(Mem)) {
5617 if (!MemRecord->isAnonymousStructOrUnion() &&
5618 MemRecord->getDeclName()) {
5621 Diag(MemRecord->getLocation(), diag::ext_anonymous_record_with_type)
5622 << Record->isUnion();
5625 Diag(MemRecord->getLocation(), diag::err_anonymous_record_with_type)
5626 << Record->isUnion();
5633 Diag(MemRecord->getLocation(),
5634 diag::ext_anonymous_record_with_anonymous_type)
5635 << Record->isUnion();
5637 }
else if (isa<AccessSpecDecl>(Mem)) {
5639 }
else if (isa<StaticAssertDecl>(Mem)) {
5644 unsigned DK = diag::err_anonymous_record_bad_member;
5645 if (isa<TypeDecl>(Mem))
5646 DK = diag::err_anonymous_record_with_type;
5647 else if (isa<FunctionDecl>(Mem))
5648 DK = diag::err_anonymous_record_with_function;
5649 else if (isa<VarDecl>(Mem))
5650 DK = diag::err_anonymous_record_with_static;
5654 DK == diag::err_anonymous_record_with_type)
5655 Diag(Mem->getLocation(), diag::ext_anonymous_record_with_type)
5656 << Record->isUnion();
5658 Diag(Mem->getLocation(), DK) << Record->isUnion();
5667 if (cast<CXXRecordDecl>(Record)->hasInClassInitializer() &&
5670 cast<CXXRecordDecl>(Record));
5673 if (!Record->isUnion() && !Owner->
isRecord()) {
5674 Diag(Record->getLocation(), diag::err_anonymous_struct_not_member)
5694 assert(TInfo &&
"couldn't build declarator info for anonymous struct/union");
5698 if (
RecordDecl *OwningClass = dyn_cast<RecordDecl>(Owner)) {
5715 Diag(Record->getLocation(), diag::err_mutable_nonmember);
5721 Record->getLocation(),
nullptr,
5734 Record->setAnonymousStructOrUnion(
true);
5745 Chain.push_back(Anon);
5750 if (
VarDecl *NewVD = dyn_cast<VarDecl>(Anon)) {
5753 Decl *ManglingContextDecl;
5754 std::tie(MCtx, ManglingContextDecl) =
5786 assert(Record &&
"expected a record!");
5791 assert(TInfo &&
"couldn't build declarator info for anonymous struct");
5799 nullptr, RecTy, TInfo,
5811 Chain.push_back(Anon);
5813 RecordDecl *RecordDef = Record->getDefinition();
5815 diag::err_field_incomplete_or_sizeless) ||
5819 ParentDecl->setInvalidDecl();
5835 NameInfo.
setLoc(Name.StartLocation);
5837 switch (Name.getKind()) {
5841 NameInfo.
setName(Name.Identifier);
5857 if (!Template || !isa<ClassTemplateDecl>(Template)) {
5858 Diag(Name.StartLocation,
5859 diag::err_deduction_guide_name_not_class_template)
5862 Diag(Template->getLocation(), diag::note_template_decl_here);
5873 Name.OperatorFunctionId.Operator));
5875 Name.OperatorFunctionId.SymbolLocations[0], Name.EndLocation));
5911 if (!CurClass || CurClass->
getIdentifier() != Name.TemplateId->Name)
5947 llvm_unreachable(
"Unknown name kind");
5975 for (
unsigned Idx = 0; Idx <
Declaration->param_size(); ++Idx) {
5989 (DeclTyName && DeclTyName == DefTyName))
5990 Params.push_back(Idx);
6017#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case DeclSpec::TST_##Trait:
6018#include "clang/Basic/TransformTypeTraits.def"
6023 if (T.isNull() || !T->isInstantiationDependentType())
break;
6033 if (!TSI)
return true;
6046 if (
Result.isInvalid())
return true;
6091 << D << static_cast<int>(Status);
6102 if (getOMPTraitInfoForSurroundingScope()->isExtensionActive(llvm::omp::TraitProperty::
6103 implementation_extension_bind_to_declaration))
6131 while (Record && Record->isAnonymousStructOrUnion())
6132 Record = dyn_cast<CXXRecordDecl>(Record->getParent());
6133 if (Record && Record->getIdentifier() && Record->getDeclName() == Name) {
6134 Diag(NameInfo.
getLoc(), diag::err_member_name_of_class) << Name;
6161 while (isa<LinkageSpecDecl>(Cur) || isa<CapturedDecl>(Cur))
6175 Diag(Loc,
LangOpts.MicrosoftExt ? diag::warn_member_extra_qualification
6176 : diag::err_member_extra_qualification)
6180 Diag(Loc, diag::warn_namespace_member_extra_qualification) << Name;
6188 if (!Cur->
Encloses(DC) && !IsTemplateId) {
6190 Diag(Loc, diag::err_member_qualification)
6192 else if (isa<TranslationUnitDecl>(DC))
6193 Diag(Loc, diag::err_invalid_declarator_global_scope)
6195 else if (isa<FunctionDecl>(Cur))
6196 Diag(Loc, diag::err_invalid_declarator_in_function)
6198 else if (isa<BlockDecl>(Cur))
6199 Diag(Loc, diag::err_invalid_declarator_in_block)
6201 else if (isa<ExportDecl>(Cur)) {
6202 if (!isa<NamespaceDecl>(DC))
6203 Diag(Loc, diag::err_export_non_namespace_scope_name)
6210 Diag(Loc, diag::err_invalid_declarator_scope)
6218 Diag(Loc, diag::err_member_qualification)
6240 if (isa_and_nonnull<DecltypeType>(
6242 Diag(Loc, diag::err_decltype_in_declarator)
6282 if (!DC || isa<EnumDecl>(DC)) {
6288 diag::err_template_qualified_declarator_no_match)
6295 if (!IsDependentContext &&
6300 if (isa<CXXRecordDecl>(DC) && !cast<CXXRecordDecl>(DC)->
hasDefinition()) {
6302 diag::err_member_def_undefined_record)
6319 if (EnteringContext && IsDependentContext &&
6320 TemplateParamLists.size() != 0) {
6339 bool IsLinkageLookup =
false;
6340 bool CreateBuiltins =
false;
6354 IsLinkageLookup =
true;
6359 CreateBuiltins =
true;
6361 if (IsLinkageLookup) {
6396 Previous.getFoundDecl()->isTemplateParameter()) {
6426 bool AddToScope =
true;
6428 if (TemplateParamLists.size()) {
6462 bool &SizeIsNegative,
6463 llvm::APSInt &Oversized) {
6468 SizeIsNegative =
false;
6471 if (T->isDependentType())
6477 if (
const PointerType* PTy = dyn_cast<PointerType>(Ty)) {
6482 if (FixedType.
isNull())
return FixedType;
6484 return Qs.
apply(Context, FixedType);
6486 if (
const ParenType* PTy = dyn_cast<ParenType>(Ty)) {
6487 QualType Inner = PTy->getInnerType();
6491 if (FixedType.
isNull())
return FixedType;
6493 return Qs.
apply(Context, FixedType);
6503 SizeIsNegative, Oversized);
6513 llvm::APSInt Res =
Result.Val.getInt();
6516 if (Res.isSigned() && Res.isNegative()) {
6517 SizeIsNegative =
true;
6522 unsigned ActiveSizeBits =
6526 : Res.getActiveBits();
6534 return Qs.
apply(Context, FoldedArrayType);
6559 TypeLoc DstElemTL = DstATL.getElementLoc();
6578 bool &SizeIsNegative,
6579 llvm::APSInt &Oversized) {
6582 SizeIsNegative, Oversized);
6595 unsigned FailedFoldDiagID) {
6596 bool SizeIsNegative;
6597 llvm::APSInt Oversized;
6599 TInfo,
Context, SizeIsNegative, Oversized);
6601 Diag(Loc, diag::ext_vla_folded_to_constant);
6608 Diag(Loc, diag::err_typecheck_negative_array_size);
6609 else if (Oversized.getBoolValue())
6610 Diag(Loc, diag::err_array_too_large) <<
toString(Oversized, 10);
6611 else if (FailedFoldDiagID)
6612 Diag(Loc, FailedFoldDiagID);
6644 diag::err_virtual_non_function);
6648 diag::err_explicit_non_function);
6652 diag::err_noreturn_non_function);
6675 << 1 <<
static_cast<int>(D.
getDeclSpec().getConstexprSpecifier());
6680 diag::err_deduction_guide_invalid_specifier)
6689 if (!NewTD)
return nullptr;
6710 if (T->isVariablyModifiedType()) {
6713 if (S->getFnParent() ==
nullptr) {
6714 bool SizeIsNegative;
6715 llvm::APSInt Oversized;
6726 else if (T->isVariableArrayType())
6728 else if (Oversized.getBoolValue())
6755 Redeclaration =
true;
6761 if (ShadowedDecl && !Redeclaration)
6768 switch (II->getInterestingIdentifierID()) {
6769 case tok::InterestingIdentifierKind::FILE:
6772 case tok::InterestingIdentifierKind::jmp_buf:
6775 case tok::InterestingIdentifierKind::sigjmp_buf:
6778 case tok::InterestingIdentifierKind::ucontext_t:
6781 case tok::InterestingIdentifierKind::float_t:
6782 case tok::InterestingIdentifierKind::double_t:
6783 NewTD->
addAttr(AvailableOnlyInDefaultEvalMethodAttr::Create(
Context));
6844 if (!OuterContext->
Equals(PrevOuterContext))
6853 if (!SS.
isSet())
return;
6862 unsigned kind = -1U;
6864 if (var->hasAttr<BlocksAttr>())
6866 else if (!var->hasLocalStorage())
6868 }
else if (isa<ObjCIvarDecl>(
decl)) {
6870 }
else if (isa<FieldDecl>(
decl)) {
6875 Diag(
decl->getLocation(), diag::err_arc_autoreleasing_var)
6880 if (!type->isObjCLifetimeType())
6883 lifetime = type->getObjCARCImplicitLifetime();
6885 decl->setType(type);
6891 var->getTLSKind()) {
6892 Diag(var->getLocation(), diag::err_arc_thread_ownership)
6902 if (
Decl->getType().hasAddressSpace())
6904 if (
Decl->getType()->isDependentType())
6916 Var->hasGlobalStorage())
6920 if (
auto DT = dyn_cast<DecayedType>(
Type)) {
6921 auto OrigTy = DT->getOriginalType();
6922 if (!OrigTy.hasAddressSpace() && OrigTy->isArrayType()) {
6954 if (WeakRefAttr *
Attr = ND.
getAttr<WeakRefAttr>()) {
6962 if (
auto *VD = dyn_cast<VarDecl>(&ND)) {
6963 if (VD->hasInit()) {
6964 if (
const auto *
Attr = VD->getAttr<AliasAttr>()) {
6965 assert(VD->isThisDeclarationADefinition() &&
6966 !VD->isExternallyVisible() &&
"Broken AliasAttr handled late!");
6968 VD->dropAttr<AliasAttr>();
6975 if (SelectAnyAttr *
Attr = ND.
getAttr<SelectAnyAttr>()) {
6978 diag::err_attribute_selectany_non_extern_data);
6984 auto *VD = dyn_cast<VarDecl>(&ND);
6985 bool IsAnonymousNS =
false;
6988 const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(VD->getDeclContext());
6989 while (NS && !IsAnonymousNS) {
6991 NS = dyn_cast<NamespaceDecl>(NS->
getParent());
6998 bool AnonNSInMicrosoftMode = IsAnonymousNS && IsMicrosoft;
7000 (!AnonNSInMicrosoftMode &&
7009 if (
const auto *FD = dyn_cast<FunctionDecl>(&ND)) {
7014 for (
TypeLoc TL = FD->getTypeSourceInfo()->getTypeLoc();
7020 if (
const auto *A = ATL.
getAttrAs<LifetimeBoundAttr>()) {
7021 const auto *MD = dyn_cast<CXXMethodDecl>(FD);
7022 if (!MD || MD->isStatic()) {
7023 S.
Diag(A->getLocation(), diag::err_lifetimebound_no_object_param)
7024 << !MD << A->getRange();
7025 }
else if (isa<CXXConstructorDecl>(MD) || isa<CXXDestructorDecl>(MD)) {
7026 S.
Diag(A->getLocation(), diag::err_lifetimebound_ctor_dtor)
7036 bool IsSpecialization,
7037 bool IsDefinition) {
7041 bool IsTemplate =
false;
7042 if (
TemplateDecl *OldTD = dyn_cast<TemplateDecl>(OldDecl)) {
7043 OldDecl = OldTD->getTemplatedDecl();
7045 if (!IsSpecialization)
7046 IsDefinition =
false;
7048 if (
TemplateDecl *NewTD = dyn_cast<TemplateDecl>(NewDecl)) {
7049 NewDecl = NewTD->getTemplatedDecl();
7053 if (!OldDecl || !NewDecl)
7056 const DLLImportAttr *OldImportAttr = OldDecl->
getAttr<DLLImportAttr>();
7057 const DLLExportAttr *OldExportAttr = OldDecl->
getAttr<DLLExportAttr>();
7058 const DLLImportAttr *NewImportAttr = NewDecl->
getAttr<DLLImportAttr>();
7059 const DLLExportAttr *NewExportAttr = NewDecl->
getAttr<DLLExportAttr>();
7063 bool HasNewAttr = (NewImportAttr && !NewImportAttr->isInherited()) ||
7064 (NewExportAttr && !NewExportAttr->isInherited());
7070 bool AddsAttr = !(OldImportAttr || OldExportAttr) && HasNewAttr;
7072 if (AddsAttr && !IsSpecialization && !OldDecl->
isImplicit()) {
7074 bool JustWarn =
false;
7076 auto *VD = dyn_cast<VarDecl>(OldDecl);
7077 if (VD && !VD->getDescribedVarTemplate())
7079 auto *FD = dyn_cast<FunctionDecl>(OldDecl);
7088 if (!isa<FunctionDecl>(OldDecl) || !NewImportAttr)
7091 unsigned DiagID = JustWarn ? diag::warn_attribute_dll_redeclaration
7092 : diag::err_attribute_dll_redeclaration;
7095 << (NewImportAttr ? (
const Attr *)NewImportAttr : NewExportAttr);
7108 bool IsInline =
false, IsStaticDataMember =
false, IsQualifiedFriend =
false;
7110 if (
const auto *VD = dyn_cast<VarDecl>(NewDecl)) {
7113 IsStaticDataMember = VD->isStaticDataMember();
7114 IsDefinition = VD->isThisDeclarationADefinition(S.
Context) !=
7116 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(NewDecl)) {
7117 IsInline = FD->isInlined();
7118 IsQualifiedFriend = FD->getQualifier() &&
7122 if (OldImportAttr && !HasNewAttr &&
7123 (!IsInline || (IsMicrosoftABI && IsTemplate)) && !IsStaticDataMember &&
7125 if (IsMicrosoftABI && IsDefinition) {
7126 if (IsSpecialization) {
7129 diag::err_attribute_dllimport_function_specialization_definition);
7130 S.
Diag(OldImportAttr->getLocation(), diag::note_attribute);
7131 NewDecl->
dropAttr<DLLImportAttr>();
7134 diag::warn_redeclaration_without_import_attribute)
7137 NewDecl->
dropAttr<DLLImportAttr>();
7138 NewDecl->
addAttr(DLLExportAttr::CreateImplicit(
7139 S.
Context, NewImportAttr->getRange()));
7141 }
else if (IsMicrosoftABI && IsSpecialization) {
7142 assert(!IsDefinition);
7146 diag::warn_redeclaration_without_attribute_prev_attribute_ignored)
7147 << NewDecl << OldImportAttr;
7149 S.
Diag(OldImportAttr->getLocation(), diag::note_previous_attribute);
7150 OldDecl->
dropAttr<DLLImportAttr>();
7151 NewDecl->
dropAttr<DLLImportAttr>();
7153 }
else if (IsInline && OldImportAttr && !IsMicrosoftABI) {
7156 OldDecl->
dropAttr<DLLImportAttr>();
7157 NewDecl->
dropAttr<DLLImportAttr>();
7159 diag::warn_dllimport_dropped_from_inline_function)
7160 << NewDecl << OldImportAttr;
7167 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewDecl)) {
7169 !NewImportAttr && !NewExportAttr) {
7170 if (
const DLLExportAttr *ParentExportAttr =
7171 MD->getParent()->getAttr<DLLExportAttr>()) {
7172 DLLExportAttr *NewAttr = ParentExportAttr->clone(S.
Context);
7173 NewAttr->setInherited(
true);
7225 return D->isExternC();
7231 isa<OMPDeclareMapperDecl>(DC))
7240 if (isa<RequiresExprBodyDecl>(DC))
7242 llvm_unreachable(
"Unexpected context");
7248 isa<OMPDeclareReductionDecl>(DC) || isa<OMPDeclareMapperDecl>(DC))
7252 llvm_unreachable(
"Unexpected context");
7299 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
7300 return FD->isExternC();
7301 if (
const auto *VD = dyn_cast<VarDecl>(D))
7302 return VD->isExternC();
7304 llvm_unreachable(
"Unknown type of decl!");
7317 diag::err_opencl_type_can_only_be_used_as_function_parameter)
7331 diag::err_invalid_type_for_program_scope_var)
7360 Se.
Diag(NewVD->
getLocation(), diag::err_opencl_half_declaration) << R;
7393 Se.
Diag(NewVD->
getLocation(), diag::err_opencl_nonconst_global_sampler);
7403template <
typename AttrTy>
7406 if (
const auto *Attribute = TND->
getAttr<AttrTy>()) {
7407 AttrTy *Clone = Attribute->clone(S.
Context);
7408 Clone->setInherited(
true);
7436 if (
const auto *ConstDecl = RD->
getAttr<ReadOnlyPlacementAttr>()) {
7438 S.
Diag(ConstDecl->getLocation(), diag::note_enforce_read_only_placement);
7456 if (!Decomp.bindings().empty()) {
7457 II = Decomp.bindings()[0].Name;
7477 bool IsLocalExternDecl = SC ==
SC_Extern &&
7496 : diag::warn_deprecated_register)
7502 if (!DC->
isRecord() && S->getFnParent() ==
nullptr) {
7518 bool IsMemberSpecialization =
false;
7519 bool IsVariableTemplateSpecialization =
false;
7521 bool IsVariableTemplate =
false;
7549 diag::err_static_out_of_line)
7561 diag::err_storage_class_for_static_member)
7565 llvm_unreachable(
"C storage class in c++!");
7570 if (
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC)) {
7576 if (Ctxt->isFunctionOrMethod()) {
7577 FunctionOrMethod = Ctxt;
7580 const CXXRecordDecl *ParentDecl = dyn_cast<CXXRecordDecl>(Ctxt);
7582 AnonStruct = ParentDecl;
7586 if (FunctionOrMethod) {
7590 diag::err_static_data_member_not_allowed_in_local_class)
7591 << Name << RD->getDeclName() << RD->getTagKind();
7592 }
else if (AnonStruct) {
7597 diag::err_static_data_member_not_allowed_in_anon_struct)
7600 }
else if (RD->isUnion()) {
7605 ? diag::warn_cxx98_compat_static_data_member_in_union
7606 : diag::ext_static_data_member_in_union) << Name;
7613 bool InvalidScope =
false;
7621 false, IsMemberSpecialization, InvalidScope);
7624 if (TemplateParams) {
7625 if (!TemplateParams->
size() &&
7630 diag::err_template_variable_noparams)
7634 TemplateParams =
nullptr;
7642 IsVariableTemplateSpecialization =
true;
7646 IsVariableTemplate =
true;
7651 ? diag::warn_cxx11_compat_variable_template
7652 : diag::ext_variable_template);
7657 if (!TemplateParamLists.empty() && IsMemberSpecialization &&
7662 "should have a 'template<>' for this decl");
7665 if (IsVariableTemplateSpecialization) {
7667 TemplateParamLists.size() > 0
7668 ? TemplateParamLists[0]->getTemplateLoc()
7671 S, D, TInfo, TemplateKWLoc, TemplateParams, SC,
7686 if (IsVariableTemplate) {
7689 TemplateParams, NewVD);
7710 bool IsExplicitSpecialization =
7712 unsigned VDTemplateParamLists =
7713 (TemplateParams && !IsExplicitSpecialization) ? 1 : 0;
7714 if (TemplateParamLists.size() > VDTemplateParamLists)
7716 Context, TemplateParamLists.drop_back(VDTemplateParamLists));
7726 diag::err_inline_declaration_block_scope) << Name
7731 : diag::ext_inline_variable);
7742 if (IsLocalExternDecl) {
7745 B->setLocalExternDecl();
7750 bool EmitTLSUnsupportedError =
false;
7763 diag::err_thread_non_global)
7771 EmitTLSUnsupportedError =
true;
7778 diag::err_thread_unsupported);
7789 diag::err_constexpr_wrong_decl_kind)
7790 <<
static_cast<int>(D.
getDeclSpec().getConstexprSpecifier());
7807 diag::err_constinit_local_variable);
7811 ConstInitAttr::Keyword_constinit));
7824 if (SC ==
SC_Static && S->getFnParent() !=
nullptr &&
7829 diag::warn_static_local_in_extern_inline);
7835 if (IsVariableTemplateSpecialization)
7840 else if (IsMemberSpecialization)
7855 B->setModulePrivate();
7865 diag::err_opencl_unknown_type_specifier)
7875 if (
const auto *ATy = dyn_cast<ArrayType>(NewVD->
getType())) {
7876 if (ATy && ATy->getElementType().isWebAssemblyReferenceType() &&
7897 if (EmitTLSUnsupportedError &&
7900 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(NewVD))))
7902 diag::err_thread_unsupported);
7904 if (EmitTLSUnsupportedError &&
7910 if (SC ==
SC_None && S->getFnParent() !=
nullptr &&
7911 (NewVD->
hasAttr<CUDASharedAttr>() ||
7912 NewVD->
hasAttr<CUDAConstantAttr>())) {
7920 assert(!NewVD->
hasAttr<DLLImportAttr>() ||
7921 NewVD->
getAttr<DLLImportAttr>()->isInherited() ||
7934 if (S->getFnParent() !=
nullptr) {
7938 Diag(E->getExprLoc(), diag::warn_asm_label_on_auto_decl) <<
Label;
7944 Diag(E->getExprLoc(), diag::err_asm_unknown_register_name) <<
Label;
7955 bool HasSizeMismatch;
7957 if (!TI.isValidGCCRegisterName(
Label))
7958 Diag(E->getExprLoc(), diag::err_asm_unknown_register_name) <<
Label;
7959 else if (!TI.validateGlobalRegisterVariable(
Label,
7962 Diag(E->getExprLoc(), diag::err_asm_invalid_global_var_reg) <<
Label;
7963 else if (HasSizeMismatch)
7964 Diag(E->getExprLoc(), diag::err_asm_register_size_mismatch) <<
Label;
7977 llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I =
7999 IsMemberSpecialization ||
8000 IsVariableTemplateSpecialization);
8021 isa<FieldDecl>(
Previous.getFoundDecl()) &&
8038 if (!IsVariableTemplateSpecialization)
8069 if (PrevVarTemplate &&
8089 Decl *ManglingContextDecl;
8090 std::tie(MCtx, ManglingContextDecl) =
8101 if (Name.getAsIdentifierInfo() && Name.getAsIdentifierInfo()->isStr(
"main") &&
8151 if (isa<TypeAliasDecl>(ShadowedDecl))
8153 else if (isa<TypedefDecl>(ShadowedDecl))
8155 else if (isa<BindingDecl>(ShadowedDecl))
8157 else if (isa<RecordDecl>(OldDC))
8240 if (
FieldDecl *FD = dyn_cast<FieldDecl>(ShadowedDecl)) {
8248 if (isa<CXXConstructorDecl>(NewDC))
8249 if (
const auto PVD = dyn_cast<ParmVarDecl>(D)) {
8252 ShadowingDecls.insert({PVD->getCanonicalDecl(), FD});
8257 if (
VarDecl *shadowedVar = dyn_cast<VarDecl>(ShadowedDecl))
8258 if (shadowedVar->isExternC()) {
8261 for (
auto *I : shadowedVar->redecls())
8262 if (I->isFileVarDecl()) {
8270 unsigned WarningDiag = diag::warn_decl_shadow;
8272 if (isa<VarDecl>(D) && isa<VarDecl>(ShadowedDecl) && NewDC &&
8273 isa<CXXMethodDecl>(NewDC)) {
8274 if (
const auto *RD = dyn_cast<CXXRecordDecl>(NewDC->
getParent())) {
8276 if (RD->getLambdaCaptureDefault() ==
LCD_None) {
8282 WarningDiag = diag::warn_decl_shadow_uncaptured_local;
8287 ->ShadowingDecls.push_back(
8293 if (cast<VarDecl>(ShadowedDecl)->hasLocalStorage()) {
8297 ParentDC && !ParentDC->
Equals(OldDC);
8301 if (!isa<BlockDecl>(ParentDC) && !isa<CapturedDecl>(ParentDC) &&
8331 Diag(CaptureLoc, diag::note_var_explicitly_captured_here)
8340 const VarDecl *ShadowedDecl = Shadow.ShadowedDecl;
8345 ? diag::warn_decl_shadow_uncaptured_local
8346 : diag::warn_decl_shadow)
8347 << Shadow.VD->getDeclName()
8350 Diag(CaptureLoc, diag::note_var_explicitly_captured_here)
8351 << Shadow.VD->getDeclName() << 0;
8375 auto *DRE = dyn_cast<DeclRefExpr>(E);
8379 auto I = ShadowingDecls.find(D);
8380 if (I == ShadowingDecls.end())
8382 const NamedDecl *ShadowedDecl = I->second;
8384 Diag(Loc, diag::warn_modifying_shadowing_decl) << D << OldDC;
8389 ShadowingDecls.erase(I);
8397 assert(S.
getLangOpts().CPlusPlus &&
"only C++ has extern \"C\"");
8418 if (!isa<VarDecl>(ND))
8428 if (isa<VarDecl>(*I)) {
8438 if (isa<VarDecl>(*I)) {
8456 assert(Prev &&
"should have found a previous declaration to diagnose");
8458 Prev = FD->getFirstDecl();
8462 S.
Diag(ND->getLocation(), diag::err_extern_c_global_conflict)
8484 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
8496 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit())
8517 if (T->isUndeducedType())
8523 if (T->isObjCObjectType()) {
8557 if (NewVD->
hasAttr<BlocksAttr>()) {
8562 if (T->isBlockPointerType()) {
8565 if (!T.isConstQualified()) {
8566 Diag(NewVD->
getLocation(), diag::err_opencl_invalid_block_declaration)
8572 Diag(NewVD->
getLocation(), diag::err_opencl_extern_block_declaration);
8581 if (!T->isSamplerT() && !T->isDependentType() &&
8588 Diag(NewVD->
getLocation(), diag::err_opencl_global_invalid_addr_space)
8589 <<
Scope <<
"global or constant";
8591 Diag(NewVD->
getLocation(), diag::err_opencl_global_invalid_addr_space)
8592 <<
Scope <<
"constant";
8608 if (FD && !FD->
hasAttr<OpenCLKernelAttr>()) {
8620 if (FD && FD->
hasAttr<OpenCLKernelAttr>()) {
8645 && !NewVD->
hasAttr<BlocksAttr>()) {
8656 if (T->isWebAssemblyTableType()) {
8667 const auto *ATy = dyn_cast<ConstantArrayType>(T.getTypePtr());
8668 if (!ATy || ATy->getSize().getSExtValue() != 0) {
8670 diag::err_typecheck_wasm_table_must_have_zero_length);
8676 bool isVM = T->isVariablyModifiedType();
8677 if (isVM || NewVD->
hasAttr<CleanupAttr>() ||
8683 bool SizeIsNegative;
8684 llvm::APSInt Oversized;
8689 FixedT = FixedTInfo->
getType();
8690 else if (FixedTInfo) {
8696 if ((!FixedTInfo || FixedT.
isNull()) && T->isVariableArrayType()) {
8729 if (T->isVoidType()) {
8747 !T.isWebAssemblyReferenceType()) {
8753 if (isVM && NewVD->
hasAttr<BlocksAttr>()) {
8759 if (NewVD->
isConstexpr() && !T->isDependentType() &&
8761 diag::err_constexpr_var_non_literal)) {
8775 if (T->isSVESizelessBuiltinType() && isa<FunctionDecl>(
CurContext)) {
8777 llvm::StringMap<bool> CallerFeatureMap;
8780 "sve", CallerFeatureMap)) {
8781 Diag(NewVD->
getLocation(), diag::err_sve_vector_in_non_sve_target) << T;
8832 CXXRecordDecl *BaseRecord = Specifier->getType()->getAsCXXRecordDecl();
8844 dyn_cast<CXXMethodDecl>(BaseND->getCanonicalDecl());
8853 if (Overridden.insert(BaseMD).second) {
8870 return !Overridden.empty();
8876 struct ActOnFDArgs {
8892 : Context(Context), OriginalFD(TypoFD),
8895 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
8901 CDeclEnd = candidate.
end();
8902 CDecl != CDeclEnd; ++CDecl) {
8909 if (
Parent &&
Parent->getCanonicalDecl() == ExpectedParent)
8911 }
else if (!ExpectedParent) {
8920 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
8921 return std::make_unique<DifferentNameValidatorCCC>(*
this);
8947 ActOnFDArgs &ExtraArgs,
bool IsLocalFriend,
Scope *S) {
8955 IsLocalFriend ? diag::err_no_matching_local_friend :
8957 diag::err_member_decl_does_not_match;
8969 "Cannot have an ambiguity in previous-declaration lookup");
8971 DifferentNameValidatorCCC CCC(SemaRef.
Context, NewFD,
8973 if (!Prev.
empty()) {
8975 Func != FuncEnd; ++Func) {
8982 MismatchedParams.empty() ? 0 : MismatchedParams.front() + 1;
8983 NearMatches.push_back(std::make_pair(FD, ParamNum));
8990 IsLocalFriend ?
nullptr : NewDC))) {
8997 CDeclEnd = Correction.
end();
8998 CDecl != CDeclEnd; ++CDecl) {
9018 ExtraArgs.S, ExtraArgs.D,
9021 ExtraArgs.AddToScope);
9032 if ((*I)->getCanonicalDecl() == Canonical)
9039 SemaRef.
PDiag(IsLocalFriend
9040 ? diag::err_no_matching_local_friend_suggest
9041 : diag::err_member_decl_does_not_match_suggest)
9042 << Name << NewDC << IsDefinition);
9055 << Name << NewDC << IsDefinition << NewFD->
getLocation();
9057 bool NewFDisConst =
false;
9059 NewFDisConst = NewMD->isConst();
9062 NearMatch = NearMatches.begin(), NearMatchEnd = NearMatches.end();
9063 NearMatch != NearMatchEnd; ++NearMatch) {
9066 bool FDisConst = MD && MD->
isConst();
9067 bool IsMember = MD || !IsLocalFriend;
9070 if (
unsigned Idx = NearMatch->second) {
9074 SemaRef.
Diag(Loc, IsMember ? diag::note_member_def_close_param_match
9075 : diag::note_local_decl_close_param_match)
9078 }
else if (FDisConst != NewFDisConst) {
9079 SemaRef.
Diag(FD->
getLocation(), diag::note_member_def_close_const_match)
9090 IsMember ? diag::note_member_def_close_match
9091 : diag::note_local_decl_close_match);
9098 default: llvm_unreachable(
"Unknown storage class!");
9103 diag::err_typecheck_sclass_func);
9120 diag::err_static_block_func);
9136 bool &IsVirtualOkay) {
9162 "Strict prototypes are required");
9180 diag::err_constexpr_wrong_decl_kind)
9181 <<
static_cast<int>(ConstexprKind);
9190 "Constructors can only be declared in a member context");
9196 isInline,
false, ConstexprKind,
9207 false, ConstexprKind,
9208 TrailingRequiresClause);
9211 if (Record->isBeingDefined())
9220 IsVirtualOkay =
true;
9232 true, ConstexprKind, TrailingRequiresClause);
9238 diag::err_conv_function_not_member);
9246 IsVirtualOkay =
true;
9251 TrailingRequiresClause);
9254 if (TrailingRequiresClause)
9256 diag::err_trailing_requires_clause_on_deduction_guide)
9268 if (Name.getAsIdentifierInfo() &&
9269 Name.getAsIdentifierInfo() == cast<CXXRecordDecl>(DC)->getIdentifier()){
9281 IsVirtualOkay = !Ret->isStatic();
9295 true , ConstexprKind, TrailingRequiresClause);
9312 StringRef SizeTypeNames[] = {
"size_t",
"intptr_t",
"uintptr_t",
"ptrdiff_t"};
9320 if (Names.end() != Match)
9325 }
while (DesugaredTy != Ty);
9364 "__cl_clang_non_portable_kernel_param_types", S.
getLangOpts())) {
9366 bool IsStandardLayoutType =
true;
9372 if (!CXXRec->hasDefinition())
9373 CXXRec = CXXRec->getTemplateInstantiationPattern();
9374 if (!CXXRec || !CXXRec->hasDefinition() || !CXXRec->isStandardLayout())
9375 IsStandardLayoutType =
false;
9378 !IsStandardLayoutType)
9426 "__cl_clang_non_portable_kernel_param_types", S.
getLangOpts()) &&
9440 llvm::SmallPtrSetImpl<const Type *> &ValidTypes) {
9453 S.
Diag(Param->getLocation(), diag::err_opencl_ptrptr_kernel_param);
9462 S.
Diag(Param->getLocation(), diag::err_kernel_arg_address_space);
9479 S.
Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT;
9487 S.
Diag(Loc, diag::note_entity_declared_at) << PT;
9488 PT = Typedef->desugar();
9510 HistoryStack.push_back(
nullptr);
9515 const RecordType *RecTy =
9517 const RecordDecl *OrigRecDecl = RecTy->getDecl();
9519 VisitStack.push_back(RecTy->getDecl());
9520 assert(VisitStack.back() &&
"First decl null?");
9523 const Decl *
Next = VisitStack.pop_back_val();
9525 assert(!HistoryStack.empty());
9527 if (
const FieldDecl *Hist = HistoryStack.pop_back_val())
9528 ValidTypes.insert(Hist->getType().getTypePtr());
9537 HistoryStack.push_back(Field);
9539 QualType FieldTy = Field->getType();
9543 "Unexpected type.");
9546 RD = FieldRecTy->
castAs<RecordType>()->getDecl();
9552 VisitStack.push_back(
nullptr);
9554 for (
const auto *FD : RD->
fields()) {
9565 VisitStack.push_back(FD);
9576 S.
Diag(Param->getLocation(),
9577 diag::err_record_with_pointers_kernel_param)
9581 S.
Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT;
9584 S.
Diag(OrigRecDecl->getLocation(), diag::note_within_field_of_type)
9585 << OrigRecDecl->getDeclName();
9590 I = HistoryStack.begin() + 1,
9591 E = HistoryStack.end();
9604 }
while (!VisitStack.empty());
9620 while (S->isClassScope() ||
9621 (LangOpts.CPlusPlus &&
9622 S->isFunctionPrototypeScope()) ||
9624 (S->getEntity() && S->getEntity()->isTransparentContext()))
9631 unsigned BuiltinID) {
9632 switch (BuiltinID) {
9633 case Builtin::BI__GetExceptionInfo:
9637 case Builtin::BIaddressof:
9638 case Builtin::BI__addressof:
9639 case Builtin::BIforward:
9640 case Builtin::BIforward_like:
9641 case Builtin::BImove:
9642 case Builtin::BImove_if_noexcept:
9643 case Builtin::BIas_const: {
9668 llvm::append_range(TemplateParamLists, TemplateParamListsRef);
9670 if (!TemplateParamLists.empty() &&
9671 Invented->getDepth() == TemplateParamLists.back()->getDepth())
9672 TemplateParamLists.back() = Invented;
9674 TemplateParamLists.push_back(Invented);
9684 diag::err_invalid_thread)
9691 bool isFriend =
false;
9693 bool isMemberSpecialization =
false;
9694 bool isFunctionTemplateSpecialization =
false;
9696 bool isDependentClassScopeExplicitSpecialization =
false;
9697 bool HasExplicitTemplateArgs =
false;
9700 bool isVirtualOkay =
false;
9707 if (!NewFD)
return nullptr;
9717 if (IsLocalExternDecl)
9726 bool ImplicitInlineCXX20 = !
getLangOpts().CPlusPlusModules ||
9749 if (
Parent->isInterface() && cast<CXXMethodDecl>(NewFD)->isUserProvided())
9754 if (isVirtual &&
Parent->isUnion()) {
9759 Parent->hasAttr<SYCLSpecialClassAttr>() &&
9762 if (
auto *Def =
Parent->getDefinition())
9763 Def->setInitMethod(
true);
9768 isMemberSpecialization =
false;
9769 isFunctionTemplateSpecialization =
false;
9783 TemplateParamLists, isFriend, isMemberSpecialization,
9785 if (TemplateParams) {
9790 if (TemplateParams->
size() > 0) {
9810 Name, TemplateParams,
9816 if (TemplateParamLists.size() > 1) {
9823 isFunctionTemplateSpecialization =
true;
9825 if (TemplateParamLists.size() > 0)
9845 << Name << RemoveRange
9853 if (!TemplateParamLists.empty() && isMemberSpecialization &&
9859 if (TemplateParamLists.size() > 0)
9876 if (!isVirtualOkay) {
9878 diag::err_virtual_non_function);
9882 diag::err_virtual_out_of_class)
9888 diag::err_virtual_member_function_template)
9924 diag::err_inline_declaration_block_scope) << Name
9934 !isa<CXXDeductionGuideDecl>(NewFD)) {
9938 diag::err_explicit_out_of_class)
9940 }
else if (!isa<CXXConstructorDecl>(NewFD) &&
9941 !isa<CXXConversionDecl>(NewFD)) {
9945 diag::err_explicit_non_ctor_or_conv_function)
9959 if (isa<CXXDestructorDecl>(NewFD) &&
9963 <<
static_cast<int>(ConstexprKind);
9977 diag::err_invalid_consteval_decl_kind)
9985 if (isFunctionTemplateSpecialization) {
9988 Diag(ModulePrivateLoc, diag::err_module_private_specialization)
10023 if (isa<CXXMethodDecl>(NewFD) && DC ==
CurContext &&
10034 if (SC ==
SC_Static && isa<CXXMethodDecl>(NewFD) &&
10049 cast<CXXRecordDecl>(DC)->getDescribedClassTemplate()) ||
10051 ? diag::ext_static_out_of_line : diag::err_static_out_of_line)
10059 if ((Name.getCXXOverloadedOperator() == OO_Delete ||
10060 Name.getCXXOverloadedOperator() == OO_Array_Delete) &&
10076 PendingInlineFuncDecls.insert(NewFD);
10083 isMemberSpecialization ||
10084 isFunctionTemplateSpecialization);
10094 llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I =
10119 for (
unsigned i = 0, e = FTI.
NumParams; i != e; ++i) {
10121 assert(Param->getDeclContext() != NewFD &&
"Was set before ?");
10122 Param->setDeclContext(NewFD);
10123 Params.push_back(Param);
10125 if (Param->isInvalidDecl())
10138 auto *TD = dyn_cast<TagDecl>(NonParmDecl);
10143 if (
auto *ECD = dyn_cast<EnumConstantDecl>(NonParmDecl))
10148 DeclContext *TagDC = TD->getLexicalDeclContext();
10152 TD->setDeclContext(NewFD);
10160 if (TagDC != PrototypeTagContext)
10161 TD->setLexicalDeclContext(TagDC);
10175 for (
const auto &AI : FT->param_types()) {
10178 Param->setScopeInfo(0, Params.size());
10179 Params.push_back(Param);
10183 "Should not need args for typedef of non-prototype fn");
10187 NewFD->setParams(Params);
10203 !NewFD->
hasAttr<SectionAttr>())
10204 NewFD->
addAttr(PragmaClangTextSectionAttr::CreateImplicit(
10210 !NewFD->
hasAttr<SectionAttr>()) {
10211 NewFD->
addAttr(SectionAttr::CreateImplicit(
10213 CodeSegStack.CurrentPragmaLocation, SectionAttr::Declspec_allocate));
10224 !NewFD->
hasAttr<StrictGuardStackCheckAttr>())
10225 NewFD->
addAttr(StrictGuardStackCheckAttr::CreateImplicit(
10230 if (!NewFD->
hasAttr<CodeSegAttr>()) {
10239 const auto *NewTVA = NewFD->
getAttr<TargetVersionAttr>();
10240 if (NewTVA && !NewTVA->isDefaultVersion() &&
10243 AddToScope =
false;
10252 Diag(NewFD->
getLocation(), diag::err_return_value_with_address_space);
10263 S->getDepth() == 0) {
10267 HLSLShaderAttr::ShaderType ShaderType =
10268 static_cast<HLSLShaderAttr::ShaderType
>(
10272 if (HLSLShaderAttr *NT = NewFD->
getAttr<HLSLShaderAttr>()) {
10273 if (NT->getType() != ShaderType)
10274 Diag(NT->getLocation(), diag::err_hlsl_entry_shader_attr_mismatch)
10286 Diag(NewFD->
getLocation(), diag::err_return_value_with_address_space);
10301 isMemberSpecialization,
10308 "previous declaration set still overloaded");
10320 CC ==
CC_X86StdCall ? diag::warn_cconv_knr : diag::err_cconv_knr;
10343 diag::ext_operator_new_delete_declared_inline)
10357 HasExplicitTemplateArgs =
true;
10360 HasExplicitTemplateArgs =
false;
10366 HasExplicitTemplateArgs =
false;
10368 assert((isFunctionTemplateSpecialization ||
10370 "should have a 'template<>' for this decl");
10372 isFunctionTemplateSpecialization =
true;
10374 }
else if (isFriend && isFunctionTemplateSpecialization) {
10381 HasExplicitTemplateArgs =
true;
10399 if (isFunctionTemplateSpecialization && isFriend &&
10401 TemplateSpecializationType::anyInstantiationDependentTemplateArguments(
10403 assert(HasExplicitTemplateArgs &&
10404 "friend function specialization without template args");
10408 }
else if (isFunctionTemplateSpecialization) {
10411 isDependentClassScopeExplicitSpecialization =
true;
10414 NewFD, (HasExplicitTemplateArgs ? &TemplateArgs :
nullptr),
10426 diag::err_explicit_specialization_inconsistent_storage_class)
10433 diag::ext_explicit_specialization_storage_class)
10437 }
else if (isMemberSpecialization && isa<CXXMethodDecl>(NewFD)) {
10443 if (!isDependentClassScopeExplicitSpecialization) {
10452 isMemberSpecialization,
10462 "previous declaration set still overloaded");
10503 struct ActOnFDArgs ExtraArgs = { S, D, TemplateParamLists,
10549 *
this,
Previous, NewFD, ExtraArgs,
false,
nullptr)) {
10550 AddToScope = ExtraArgs.AddToScope;
10557 }
else if (isFriend && cast<CXXRecordDecl>(
CurContext)->isLocalClass()) {
10559 *
this,
Previous, NewFD, ExtraArgs,
true, S)) {
10560 AddToScope = ExtraArgs.AddToScope;
10565 isa<CXXMethodDecl>(NewFD) && NewFD->
isOutOfLine() &&
10566 !isFriend && !isFunctionTemplateSpecialization &&
10567 !isMemberSpecialization) {
10584 if (
unsigned BuiltinID = II->getBuiltinID()) {
10586 if (!InStdNamespace &&
10592 NewFD->
addAttr(BuiltinAttr::CreateImplicit(
Context, BuiltinID));
10601 NewFD->
addAttr(BuiltinAttr::CreateImplicit(
Context, BuiltinID));
10606 NewFD->
addAttr(BuiltinAttr::CreateImplicit(
Context, BuiltinID));
10617 if (NewFD->
hasAttr<OverloadableAttr>() &&
10620 diag::err_attribute_overloadable_no_prototype)
10622 NewFD->
dropAttr<OverloadableAttr>();
10655 isMemberSpecialization ||
10656 isFunctionTemplateSpecialization,
10675 (NewFD->
hasAttr<CUDADeviceAttr>() ||
10676 NewFD->
hasAttr<CUDAGlobalAttr>()) &&
10741 if (
getLangOpts().getOpenCLCompatibleVersion() >= 200) {
10743 QualType ElemTy = PipeTy->getElementType();
10745 Diag(Param->getTypeSpecStartLoc(), diag::err_reference_pipe_type );
10753 Diag(Param->getTypeSpecStartLoc(),
10754 diag::err_wasm_table_as_function_parameter);
10763 if (isDependentClassScopeExplicitSpecialization) {
10767 cast<CXXMethodDecl>(NewFD),
10768 HasExplicitTemplateArgs, TemplateArgs);
10770 AddToScope =
false;
10775 if (
const auto *
attr = NewFD->
getAttr<AvailabilityAttr>()) {
10776 if (NewFD->
hasAttr<ConstructorAttr>()) {
10777 Diag(
attr->getLocation(), diag::warn_availability_on_static_initializer)
10779 NewFD->
dropAttr<AvailabilityAttr>();
10781 if (NewFD->
hasAttr<DestructorAttr>()) {
10782 Diag(
attr->getLocation(), diag::warn_availability_on_static_initializer)
10784 NewFD->
dropAttr<AvailabilityAttr>();
10795 if (
const auto *NBA = NewFD->
getAttr<NoBuiltinAttr>())
10799 Diag(NBA->getLocation(),
10800 diag::err_attribute_no_builtin_on_defaulted_deleted_function)
10801 << NBA->getSpelling();
10804 Diag(NBA->getLocation(), diag::err_attribute_no_builtin_on_non_definition)
10805 << NBA->getSpelling();
10825 const auto *Method = dyn_cast<CXXMethodDecl>(FD);
10829 if (
const auto *SAttr =
Parent->getAttr<CodeSegAttr>()) {
10840 while ((
Parent = dyn_cast<CXXRecordDecl>(
Parent->getParent()))) {
10841 if (
const auto *SAttr =
Parent->getAttr<CodeSegAttr>()) {
10860 bool IsDefinition) {
10863 if (!FD->
hasAttr<SectionAttr>() && IsDefinition &&
10865 return SectionAttr::CreateImplicit(
10867 CodeSegStack.CurrentPragmaLocation, SectionAttr::Declspec_allocate);
10932 auto *VD = dyn_cast<ValueDecl>(D);
10933 auto *PrevVD = dyn_cast<ValueDecl>(PrevDecl);
10934 return !VD || !PrevVD ||
10936 PrevVD->getType());
10944 const auto *TA = FD->
getAttr<TargetAttr>();
10945 const auto *TVA = FD->
getAttr<TargetVersionAttr>();
10948 "MultiVersion candidate requires a target or target_version attribute");
10950 enum ErrType { Feature = 0, Architecture = 1 };
10957 << Architecture << ParseInfo.
CPU;
10960 for (
const auto &Feat : ParseInfo.
Features) {
10961 auto BareFeat = StringRef{Feat}.substr(1);
10962 if (Feat[0] ==
'-') {
10964 << Feature << (
"no-" + BareFeat).str();
10971 << Feature << BareFeat;
10979 TVA->getFeatures(Feats);
10980 for (
const auto &Feat : Feats) {
10983 << Feature << Feat;
11002 case attr::NonNull:
11003 case attr::NoThrow:
11012 const auto Diagnose = [FD, CausedFD, MVKind](
Sema &S,
const Attr *A) {
11013 S.
Diag(FD->
getLocation(), diag::err_multiversion_disallowed_other_attr)
11014 <<
static_cast<unsigned>(MVKind) << A;
11016 S.
Diag(CausedFD->
getLocation(), diag::note_multiversioning_caused_here);
11021 switch (A->getKind()) {
11022 case attr::CPUDispatch:
11023 case attr::CPUSpecific:
11026 return Diagnose(S, A);
11030 return Diagnose(S, A);
11032 case attr::TargetVersion:
11034 return Diagnose(S, A);
11036 case attr::TargetClones:
11038 return Diagnose(S, A);
11042 return Diagnose(S, A);
11055 bool ConstexprSupported,
bool CLinkageMayDiffer) {
11056 enum DoesntSupport {
11063 DefaultedFuncs = 6,
11064 ConstexprFuncs = 7,
11065 ConstevalFuncs = 8,
11077 if (NoProtoDiagID.
getDiagID() != 0 && OldFD &&
11080 Diag(NoteCausedDiagIDAt.first, NoteCausedDiagIDAt.second);
11088 if (!TemplatesSupported &&
11090 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11093 if (
const auto *NewCXXFD = dyn_cast<CXXMethodDecl>(NewFD)) {
11094 if (NewCXXFD->isVirtual())
11095 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11098 if (isa<CXXConstructorDecl>(NewCXXFD))
11099 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11102 if (isa<CXXDestructorDecl>(NewCXXFD))
11103 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11108 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11112 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11116 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11117 << (NewFD->
isConsteval() ? ConstevalFuncs : ConstexprFuncs);
11121 QualType NewReturnType = NewType->getReturnType();
11124 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
11134 if (OldTypeInfo.
getCC() != NewTypeInfo.
getCC())
11137 QualType OldReturnType = OldType->getReturnType();
11139 if (OldReturnType != NewReturnType)
11140 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) << ReturnType;
11143 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) << ConstexprSpec;
11146 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) << InlineSpec;
11149 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) <<
Linkage;
11173 bool IsCPUSpecificCPUDispatchMVKind =
11177 if (CausesMV && OldFD &&
11185 if (OldFD && CausesMV && OldFD->
isUsed(
false))
11186 return S.
Diag(NewFD->
getLocation(), diag::err_multiversion_after_used);
11189 OldFD, NewFD, S.
PDiag(diag::err_multiversion_noproto),
11191 S.
PDiag(diag::note_multiversioning_caused_here)),
11193 S.
PDiag(diag::err_multiversion_doesnt_support)
11194 <<
static_cast<unsigned>(MVKind)),
11196 S.
PDiag(diag::err_multiversion_diff)),
11198 !IsCPUSpecificCPUDispatchMVKind,
11211 "Function lacks multiversion attribute");
11212 const auto *TA = FD->
getAttr<TargetAttr>();
11213 const auto *TVA = FD->
getAttr<TargetVersionAttr>();
11216 if ((TA && !TA->isDefaultVersion()) || (TVA && !TVA->isDefaultVersion()))
11244 bool &Redeclaration,
11247 const auto *NewTA = NewFD->
getAttr<TargetAttr>();
11248 const auto *NewTVA = NewFD->
getAttr<TargetVersionAttr>();
11249 const auto *OldTA = OldFD->
getAttr<TargetAttr>();
11250 const auto *OldTVA = OldFD->
getAttr<TargetVersionAttr>();
11253 if ((NewTA && !NewTA->isDefaultVersion() &&
11254 (!OldTA || OldTA->getFeaturesStr() == NewTA->getFeaturesStr())) ||
11255 (NewTVA && !NewTVA->isDefaultVersion() &&
11256 (!OldTVA || OldTVA->getName() == NewTVA->getName())))
11274 ((NewTA && NewTA->isDefaultVersion() && !OldTA) ||
11275 (NewTVA && NewTVA->isDefaultVersion() && !OldTVA))) {
11276 Redeclaration =
true;
11284 S.
Diag(NewFD->
getLocation(), diag::note_multiversioning_caused_here);
11292 OldTA->getFeaturesStr());
11296 NewTA->getFeaturesStr());
11299 if (OldParsed == NewParsed) {
11309 OldTVA->getFeatures(Feats);
11312 NewTVA->getFeatures(NewFeats);
11313 llvm::sort(NewFeats);
11315 if (Feats == NewFeats) {
11323 for (
const auto *FD : OldFD->
redecls()) {
11324 const auto *CurTA = FD->
getAttr<TargetAttr>();
11325 const auto *CurTVA = FD->
getAttr<TargetVersionAttr>();
11329 ((NewTA && (!CurTA || CurTA->isInherited())) ||
11330 (NewTVA && (!CurTVA || CurTVA->isInherited())))) {
11332 << (NewTA ? 0 : 2);
11333 S.
Diag(NewFD->
getLocation(), diag::note_multiversioning_caused_here);
11341 Redeclaration =
false;
11364 const CPUSpecificAttr *NewCPUSpec,
const TargetClonesAttr *NewClones,
11366 const auto *NewTA = NewFD->
getAttr<TargetAttr>();
11367 const auto *NewTVA = NewFD->
getAttr<TargetVersionAttr>();
11380 NewTA->getFeaturesStr());
11385 NewTVA->getFeatures(NewFeats);
11386 llvm::sort(NewFeats);
11389 bool UseMemberUsingDeclRules =
11392 bool MayNeedOverloadableChecks =
11401 if (MayNeedOverloadableChecks &&
11402 S.
IsOverload(NewFD, CurFD, UseMemberUsingDeclRules))
11407 NewFD->
addAttr(TargetVersionAttr::CreateImplicit(
11412 NewTVA = NewFD->
getAttr<TargetVersionAttr>();
11413 NewTVA->getFeatures(NewFeats);
11414 llvm::sort(NewFeats);
11418 switch (NewMVKind) {
11421 "Only target_clones can be omitted in subsequent declarations");
11424 const auto *CurTA = CurFD->
getAttr<TargetAttr>();
11425 if (CurTA->getFeaturesStr() == NewTA->getFeaturesStr()) {
11427 Redeclaration =
true;
11434 CurTA->getFeaturesStr());
11436 if (CurParsed == NewParsed) {
11445 const auto *CurTVA = CurFD->
getAttr<TargetVersionAttr>();
11446 if (CurTVA->getName() == NewTVA->getName()) {
11448 Redeclaration =
true;
11454 CurTVA->getFeatures(CurFeats);
11455 llvm::sort(CurFeats);
11457 if (CurFeats == NewFeats) {
11466 const auto *CurClones = CurFD->
getAttr<TargetClonesAttr>();
11467 Redeclaration =
true;
11471 if (CurClones && NewClones &&
11472 (CurClones->featuresStrs_size() != NewClones->featuresStrs_size() ||
11473 !std::equal(CurClones->featuresStrs_begin(),
11474 CurClones->featuresStrs_end(),
11475 NewClones->featuresStrs_begin()))) {
11486 const auto *CurCPUSpec = CurFD->
getAttr<CPUSpecificAttr>();
11487 const auto *CurCPUDisp = CurFD->
getAttr<CPUDispatchAttr>();
11492 CurFD->
hasAttr<CPUDispatchAttr>()) {
11493 if (CurCPUDisp->cpus_size() == NewCPUDisp->cpus_size() &&
11495 CurCPUDisp->cpus_begin(), CurCPUDisp->cpus_end(),
11496 NewCPUDisp->cpus_begin(),
11498 return Cur->getName() == New->getName();
11501 Redeclaration =
true;
11513 if (CurCPUSpec->cpus_size() == NewCPUSpec->cpus_size() &&
11515 CurCPUSpec->cpus_begin(), CurCPUSpec->cpus_end(),
11516 NewCPUSpec->cpus_begin(),
11518 return Cur->getName() == New->getName();
11521 Redeclaration =
true;
11529 if (CurII == NewII) {
11564 Redeclaration =
true;
11570 Redeclaration =
false;
11583 bool &Redeclaration,
NamedDecl *&OldDecl,
11585 const auto *NewTA = NewFD->
getAttr<TargetAttr>();
11586 const auto *NewTVA = NewFD->
getAttr<TargetVersionAttr>();
11587 const auto *NewCPUDisp = NewFD->
getAttr<CPUDispatchAttr>();
11588 const auto *NewCPUSpec = NewFD->
getAttr<CPUSpecificAttr>();
11589 const auto *NewClones = NewFD->
getAttr<TargetClonesAttr>();
11599 NewTVA->isDefaultVersion())) {
11600 S.
Diag(NewFD->
getLocation(), diag::err_multiversion_not_allowed_on_main);
11626 const auto *OldTVA = OldFD->
getAttr<TargetVersionAttr>();
11628 NewFD->
addAttr(TargetVersionAttr::CreateImplicit(
11633 Redeclaration =
true;
11645 S.
Diag(NewFD->
getLocation(), diag::err_multiversion_required_in_redecl)
11658 if (OldFD->
isUsed(
false)) {
11660 return S.
Diag(NewFD->
getLocation(), diag::err_multiversion_after_used);
11676 NewCPUSpec, NewClones, Redeclaration,
11699 bool IsMemberSpecialization,
11702 "Variably modified return types are not handled here");
11707 bool MergeTypeWithPrevious = !
getLangOpts().CPlusPlus &&
11710 bool Redeclaration =
false;
11712 bool MayNeedOverloadableChecks =
false;
11723 if (shouldLinkPossiblyHiddenDecl(Candidate, NewFD)) {
11724 Redeclaration =
true;
11725 OldDecl = Candidate;
11728 MayNeedOverloadableChecks =
true;
11732 Redeclaration =
true;
11736 Redeclaration =
true;
11740 Redeclaration =
false;
11747 if (!Redeclaration &&
11752 Redeclaration =
true;
11753 OldDecl =
Previous.getFoundDecl();
11754 MergeTypeWithPrevious =
false;
11757 if (OldDecl->
hasAttr<OverloadableAttr>() ||
11758 NewFD->
hasAttr<OverloadableAttr>()) {
11759 if (
IsOverload(NewFD, cast<FunctionDecl>(OldDecl),
false)) {
11760 MayNeedOverloadableChecks =
true;
11761 Redeclaration =
false;
11769 return Redeclaration;
11788 !MD->
isStatic() && !isa<CXXConstructorDecl>(MD) &&
11792 OldMD = dyn_cast_or_null<CXXMethodDecl>(OldDecl->
getAsFunction());
11793 if (!OldMD || !OldMD->
isStatic()) {
11815 if (Redeclaration) {
11821 return Redeclaration;
11828 dyn_cast<FunctionTemplateDecl>(OldDecl)) {
11829 auto *OldFD = OldTemplateDecl->getTemplatedDecl();
11832 assert(NewTemplateDecl &&
"Template/non-template mismatch");
11841 NewFD->
setAccess(OldTemplateDecl->getAccess());
11842 NewTemplateDecl->
setAccess(OldTemplateDecl->getAccess());
11847 if (IsMemberSpecialization &&
11850 assert(OldTemplateDecl->isMemberSpecialization());
11853 if (OldFD->isDeleted()) {
11855 assert(OldFD->getCanonicalDecl() == OldFD);
11857 OldFD->setDeletedAsWritten(
false);
11871 !NewFD->
getAttr<OverloadableAttr>()) {
11875 return ND->hasAttr<OverloadableAttr>();
11877 "Non-redecls shouldn't happen without overloadable present");
11880 const auto *FD = dyn_cast<FunctionDecl>(ND);
11881 return FD && !FD->
hasAttr<OverloadableAttr>();
11884 if (OtherUnmarkedIter !=
Previous.end()) {
11886 diag::err_attribute_overloadable_multiple_unmarked_overloads);
11887 Diag((*OtherUnmarkedIter)->getLocation(),
11888 diag::note_attribute_overloadable_prev_overload)
11905 dyn_cast<CXXDestructorDecl>(NewFD)) {
11913 !Destructor->getThisType()->isDependentType()) {
11922 return Redeclaration;
11925 }
else if (
auto *Guide = dyn_cast<CXXDeductionGuideDecl>(NewFD)) {
11926 if (
auto *TD = Guide->getDescribedFunctionTemplate())
11932 Diag(Guide->getBeginLoc(), diag::err_deduction_guide_specialized)
11937 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(NewFD)) {
11938 if (!Method->isFunctionTemplateSpecialization() &&
11939 !Method->getDescribedFunctionTemplate() &&
11940 Method->isCanonicalDecl()) {
11947 diag::err_constrained_virtual_method);
11949 if (Method->isStatic())
11979 !(isa<CXXMethodDecl>(NewFD) && NewFD->
isTemplated()) &&
11983 Diag(TRC->getBeginLoc(), diag::err_constrained_non_templated_function);
11994 return Redeclaration;
12001 return Redeclaration;
12021 Diag(NewFD->
getLocation(), diag::warn_return_value_udt) << NewFD << R;
12034 auto HasNoexcept = [&](
QualType T) ->
bool {
12039 T = RT->getPointeeType();
12040 else if (T->isAnyPointerType())
12041 T = T->getPointeeType();
12043 T = MPT->getPointeeType();
12045 if (FPT->isNothrow())
12051 bool AnyNoexcept = HasNoexcept(FPT->getReturnType());
12052 for (
QualType T : FPT->param_types())
12053 AnyNoexcept |= HasNoexcept(T);
12056 diag::warn_cxx17_compat_exception_spec_in_signature)
12060 if (!Redeclaration &&
LangOpts.CUDA)
12063 return Redeclaration;
12076 ? diag::err_static_main : diag::warn_static_main)
12084 Diag(NoreturnLoc, diag::ext_noreturn_main);
12085 Diag(NoreturnLoc, diag::note_main_remove_noreturn)
12097 << FD->
hasAttr<OpenCLKernelAttr>();
12108 assert(T->isFunctionType() &&
"function decl is not of function type");
12130 Diag(RTRange.
getBegin(), diag::note_main_change_return_type)
12152 if (isa<FunctionNoProtoType>(FT))
return;
12158 bool HasExtraParameters = (nparams > 3);
12170 HasExtraParameters =
false;
12172 if (HasExtraParameters) {
12185 for (
unsigned i = 0; i < nparams; ++i) {
12188 bool mismatch =
true;
12205 mismatch = !qs.
empty();
12234 if (T.isWindowsGNUEnvironment())
12239 if (T.isOSWindows() && T.getArch() == llvm::Triple::x86)
12247 assert(T->isFunctionType() &&
"function decl is not of function type");
12256 if (FD->
getName() !=
"DllMain")
12283 switch (Triple.getEnvironment()) {
12287 case llvm::Triple::EnvironmentType::Compute:
12288 if (!FD->
hasAttr<HLSLNumThreadsAttr>()) {
12290 << Triple.getEnvironmentName();
12296 for (
const auto *Param : FD->
parameters()) {
12301 Diag(Param->getLocation(), diag::note_previous_decl) << Param;
12318 if (Init->isValueDependent()) {
12319 assert(Init->containsErrors() &&
12320 "Dependent code should only occur in error-recovery path.");
12323 const Expr *Culprit;
12324 if (Init->isConstantInitializer(
Context,
false, &Culprit))
12326 Diag(Culprit->
getExprLoc(), diag::err_init_element_not_constant)
12334 class SelfReferenceChecker
12340 bool isReferenceType;
12348 SelfReferenceChecker(
Sema &S,
Decl *OrigDecl) : Inherited(S.Context),
12349 S(S), OrigDecl(OrigDecl) {
12352 isReferenceType =
false;
12353 isInitList =
false;
12354 if (
ValueDecl *VD = dyn_cast<ValueDecl>(OrigDecl)) {
12355 isPODType = VD->getType().isPODType(S.
Context);
12357 isReferenceType = VD->getType()->isReferenceType();
12364 void CheckExpr(
Expr *E) {
12373 InitFieldIndex.push_back(0);
12374 for (
auto *Child : InitList->
children()) {
12375 CheckExpr(cast<Expr>(Child));
12376 ++InitFieldIndex.back();
12378 InitFieldIndex.pop_back();
12383 bool CheckInitListMemberExpr(
MemberExpr *E,
bool CheckReference) {
12386 bool ReferenceField =
false;
12390 FieldDecl *FD = dyn_cast<FieldDecl>(ME->getMemberDecl());
12393 Fields.push_back(FD);
12395 ReferenceField =
true;
12396 Base = ME->getBase()->IgnoreParenImpCasts();
12401 if (!DRE || DRE->
getDecl() != OrigDecl)
12405 if (CheckReference && !ReferenceField)
12410 for (
const FieldDecl *I : llvm::reverse(Fields))
12411 UsedFieldIndex.push_back(I->getFieldIndex());
12416 for (
auto UsedIter = UsedFieldIndex.begin(),
12417 UsedEnd = UsedFieldIndex.end(),
12418 OrigIter = InitFieldIndex.begin(),
12419 OrigEnd = InitFieldIndex.end();
12420 UsedIter != UsedEnd && OrigIter != OrigEnd; ++UsedIter, ++OrigIter) {
12421 if (*UsedIter < *OrigIter)
12423 if (*UsedIter > *OrigIter)
12428 HandleDeclRefExpr(DRE);
12435 void HandleValue(
Expr *E) {
12437 if (
DeclRefExpr* DRE = dyn_cast<DeclRefExpr>(E)) {
12438 HandleDeclRefExpr(DRE);
12443 Visit(CO->getCond());
12444 HandleValue(CO->getTrueExpr());
12445 HandleValue(CO->getFalseExpr());
12450 dyn_cast<BinaryConditionalOperator>(E)) {
12451 Visit(BCO->getCond());
12452 HandleValue(BCO->getFalseExpr());
12457 HandleValue(OVE->getSourceExpr());
12462 if (BO->getOpcode() == BO_Comma) {
12463 Visit(BO->getLHS());
12464 HandleValue(BO->getRHS());
12469 if (isa<MemberExpr>(E)) {
12471 if (CheckInitListMemberExpr(cast<MemberExpr>(E),
12479 if (!isa<FieldDecl>(ME->getMemberDecl()))
12481 Base = ME->getBase()->IgnoreParenImpCasts();
12484 HandleDeclRefExpr(DRE);
12494 if (isReferenceType)
12495 HandleDeclRefExpr(E);
12504 Inherited::VisitImplicitCastExpr(E);
12509 if (CheckInitListMemberExpr(E,
true ))
12519 bool Warn = (MD && !MD->
isStatic());
12522 if (!isa<FieldDecl>(ME->getMemberDecl()))
12524 Base = ME->getBase()->IgnoreParenImpCasts();
12529 HandleDeclRefExpr(DRE);
12541 if (isa<UnresolvedLookupExpr>(Callee))
12542 return Inherited::VisitCXXOperatorCallExpr(E);
12546 HandleValue(Arg->IgnoreParenImpCasts());
12563 Inherited::VisitUnaryOperator(E);
12571 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
12572 if (ILE->getNumInits() == 1)
12573 ArgExpr = ILE->getInit(0);
12575 if (ICE->getCastKind() == CK_NoOp)
12576 ArgExpr = ICE->getSubExpr();
12577 HandleValue(ArgExpr);
12580 Inherited::VisitCXXConstructExpr(E);
12586 HandleValue(E->
getArg(0));
12590 Inherited::VisitCallExpr(E);
12595 HandleValue(E->
getLHS());
12600 Inherited::VisitBinaryOperator(E);
12613 if (OrigDecl != ReferenceDecl)
return;
12615 if (isReferenceType) {
12616 diag = diag::warn_uninit_self_reference_in_reference_init;
12617 }
else if (cast<VarDecl>(OrigDecl)->isStaticLocal()) {
12618 diag = diag::warn_static_self_reference_in_init;
12619 }
else if (isa<TranslationUnitDecl>(OrigDecl->
getDeclContext()) ||
12622 diag = diag::warn_uninit_self_reference_in_init;
12636 static void CheckSelfReference(
Sema &S,
Decl* OrigDecl,
Expr *E,
12640 if (isa<ParmVarDecl>(OrigDecl))
12649 if (ICE->getCastKind() == CK_LValueToRValue)
12650 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ICE->getSubExpr()))
12651 if (DRE->
getDecl() == OrigDecl)
12654 SelfReferenceChecker(S, OrigDecl).CheckExpr(E);
12661 struct VarDeclOrName {
12667 return VN.VDecl ?
Diag << VN.VDecl :
Diag << VN.Name;
12677 bool IsInitCapture = !VDecl;
12679 "init captures are expected to be deduced prior to initialization");
12681 VarDeclOrName VN{VDecl, Name};
12684 assert(Deduced &&
"deduceVarTypeFromInitializer for non-deduced type");
12688 assert(VDecl &&
"no init for init capture deduction?");
12692 if (!isa<DeducedTemplateSpecializationType>(Deduced) ||
12703 DeduceInits = Init;
12705 auto *PL = dyn_cast_if_present<ParenListExpr>(Init);
12707 DeduceInits = PL->exprs();
12709 if (isa<DeducedTemplateSpecializationType>(Deduced)) {
12710 assert(VDecl &&
"non-auto type for init capture deduction?");
12721 if (
auto *IL = dyn_cast<InitListExpr>(Init))
12722 DeduceInits = IL->inits();
12726 if (DeduceInits.empty()) {
12729 Diag(Init->getBeginLoc(), IsInitCapture
12730 ? diag::err_init_capture_no_expression
12731 : diag::err_auto_var_init_no_expression)
12732 << VN <<
Type << Range;
12736 if (DeduceInits.size() > 1) {
12737 Diag(DeduceInits[1]->getBeginLoc(),
12738 IsInitCapture ? diag::err_init_capture_multiple_expressions
12739 : diag::err_auto_var_init_multiple_expressions)
12740 << VN <<
Type << Range;
12744 Expr *DeduceInit = DeduceInits[0];
12745 if (
DirectInit && isa<InitListExpr>(DeduceInit)) {
12746 Diag(Init->getBeginLoc(), IsInitCapture
12747 ? diag::err_init_capture_paren_braces
12748 : diag::err_auto_var_init_paren_braces)
12754 bool DefaultedAnyToId =
false;
12758 if (
Result.isInvalid()) {
12762 DefaultedAnyToId =
true;
12768 if (VDecl && isa<DecompositionDecl>(VDecl) &&
12772 Type.getQualifiers());
12779 if (!IsInitCapture)
12781 else if (isa<InitListExpr>(Init))
12782 Diag(Range.getBegin(),
12783 diag::err_init_capture_deduction_failure_from_init_list)
12789 Diag(Range.getBegin(), diag::err_init_capture_deduction_failure)
12804 Diag(Loc, diag::warn_auto_var_is_id) << VN << Range;
12807 return DeducedType;
12812 assert(!Init || !Init->containsErrors());
12816 if (DeducedType.
isNull()) {
12846 if (
auto *EWC = dyn_cast<ExprWithCleanups>(Init))
12847 Init = EWC->getSubExpr();
12849 if (
auto *CE = dyn_cast<ConstantExpr>(Init))
12850 Init = CE->getSubExpr();
12852 QualType InitType = Init->getType();
12855 "shouldn't be called if type doesn't have a non-trivial C struct");
12856 if (
auto *ILE = dyn_cast<InitListExpr>(Init)) {
12857 for (
auto *I : ILE->inits()) {
12858 if (!I->getType().hasNonTrivialToPrimitiveDefaultInitializeCUnion() &&
12859 !I->getType().hasNonTrivialToPrimitiveCopyCUnion())
12867 if (isa<ImplicitValueInitExpr>(Init)) {
12883bool shouldIgnoreForRecordTriviality(
const FieldDecl *FD) {
12889 return FD->
hasAttr<UnavailableAttr>();
12892struct DiagNonTrivalCUnionDefaultInitializeVisitor
12899 DiagNonTrivalCUnionDefaultInitializeVisitor(
12902 : OrigTy(OrigTy), OrigLoc(OrigLoc), UseContext(UseContext), S(S) {}
12905 const FieldDecl *FD,
bool InNonTrivialUnion) {
12908 InNonTrivialUnion);
12909 return Super::visitWithKind(PDIK, QT, FD, InNonTrivialUnion);
12913 bool InNonTrivialUnion) {
12914 if (InNonTrivialUnion)
12916 << 1 << 0 << QT << FD->
getName();
12920 if (InNonTrivialUnion)
12922 << 1 << 0 << QT << FD->
getName();
12928 if (OrigLoc.isValid()) {
12929 bool IsUnion =
false;
12930 if (
auto *OrigRD = OrigTy->getAsRecordDecl())
12931 IsUnion = OrigRD->isUnion();
12932 S.
Diag(OrigLoc, diag::err_non_trivial_c_union_in_invalid_context)
12933 << 0 << OrigTy << IsUnion << UseContext;
12937 InNonTrivialUnion =
true;
12940 if (InNonTrivialUnion)
12945 if (!shouldIgnoreForRecordTriviality(FD))
12946 asDerived().visit(FD->
getType(), FD, InNonTrivialUnion);
12959struct DiagNonTrivalCUnionDestructedTypeVisitor
12964 DiagNonTrivalCUnionDestructedTypeVisitor(
12967 : OrigTy(OrigTy), OrigLoc(OrigLoc), UseContext(UseContext), S(S) {}
12970 const FieldDecl *FD,
bool InNonTrivialUnion) {
12973 InNonTrivialUnion);
12974 return Super::visitWithKind(DK, QT, FD, InNonTrivialUnion);
12978 bool InNonTrivialUnion) {
12979 if (InNonTrivialUnion)
12981 << 1 << 1 << QT << FD->
getName();
12985 if (InNonTrivialUnion)
12987 << 1 << 1 << QT << FD->
getName();
12993 if (OrigLoc.isValid()) {
12994 bool IsUnion =
false;
12995 if (
auto *OrigRD = OrigTy->getAsRecordDecl())
12996 IsUnion = OrigRD->isUnion();
12997 S.
Diag(OrigLoc, diag::err_non_trivial_c_union_in_invalid_context)
12998 << 1 << OrigTy << IsUnion << UseContext;
13002 InNonTrivialUnion =
true;
13005 if (InNonTrivialUnion)
13010 if (!shouldIgnoreForRecordTriviality(FD))
13011 asDerived().visit(FD->
getType(), FD, InNonTrivialUnion);
13016 bool InNonTrivialUnion) {}
13026struct DiagNonTrivalCUnionCopyVisitor
13033 : OrigTy(OrigTy), OrigLoc(OrigLoc), UseContext(UseContext), S(S) {}
13036 const FieldDecl *FD,
bool InNonTrivialUnion) {
13039 InNonTrivialUnion);
13040 return Super::visitWithKind(PCK, QT, FD, InNonTrivialUnion);
13044 bool InNonTrivialUnion) {
13045 if (InNonTrivialUnion)
13047 << 1 << 2 << QT << FD->
getName();
13051 if (InNonTrivialUnion)
13053 << 1 << 2 << QT << FD->
getName();
13059 if (OrigLoc.isValid()) {
13060 bool IsUnion =
false;
13061 if (
auto *OrigRD = OrigTy->getAsRecordDecl())
13062 IsUnion = OrigRD->isUnion();
13063 S.
Diag(OrigLoc, diag::err_non_trivial_c_union_in_invalid_context)
13064 << 2 << OrigTy << IsUnion << UseContext;
13068 InNonTrivialUnion =
true;
13071 if (InNonTrivialUnion)
13076 if (!shouldIgnoreForRecordTriviality(FD))
13077 asDerived().visit(FD->
getType(), FD, InNonTrivialUnion);
13081 const FieldDecl *FD,
bool InNonTrivialUnion) {}
13084 bool InNonTrivialUnion) {}
13098 unsigned NonTrivialKind) {
13102 "shouldn't be called if type doesn't have a non-trivial C union");
13106 DiagNonTrivalCUnionDefaultInitializeVisitor(QT, Loc, UseContext, *
this)
13107 .visit(QT,
nullptr,
false);
13110 DiagNonTrivalCUnionDestructedTypeVisitor(QT, Loc, UseContext, *
this)
13111 .visit(QT,
nullptr,
false);
13113 DiagNonTrivalCUnionCopyVisitor(QT, Loc, UseContext, *
this)
13114 .visit(QT,
nullptr,
false);
13128 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(RealDecl)) {
13130 Diag(Method->getLocation(), diag::err_member_function_initialization)
13131 << Method->getDeclName() << Init->getSourceRange();
13132 Method->setInvalidDecl();
13136 VarDecl *VDecl = dyn_cast<VarDecl>(RealDecl);
13138 assert(!isa<FieldDecl>(RealDecl) &&
"field init shouldn't get here");
13145 if (Init && !Init->getType().isNull() &&
13146 Init->getType()->isWebAssemblyTableType()) {
13147 Diag(Init->getExprLoc(), diag::err_wasm_table_art) << 0;
13178 Diag(VDecl->
getLocation(), diag::err_attribute_dllimport_data_definition);
13199 BaseDeclType = Array->getElementType();
13201 diag::err_typecheck_decl_incomplete_type)) {
13208 diag::err_abstract_type_in_decl,
13219 !isa<VarTemplateSpecializationDecl>(VDecl)) {
13228 if (Def != VDecl &&
13248 Diag(Init->getExprLoc(), diag::err_static_data_member_reinitialization)
13251 diag::note_previous_initializer)
13274 if (VDecl->
hasAttr<LoaderUninitializedAttr>()) {
13275 Diag(VDecl->
getLocation(), diag::err_loader_uninitialized_cant_init);
13289 if (
Result.isInvalid()) {
13297 ParenListExpr *CXXDirectInit = dyn_cast<ParenListExpr>(Init);
13298 bool IsParenListInit =
false;
13310 for (
size_t Idx = 0; Idx < Args.size(); ++Idx) {
13312 Args[Idx], VDecl,
true,
13313 [
this, Entity, Kind](
Expr *E) {
13315 return Init.Failed() ?
ExprError() : E;
13319 }
else if (Res.
get() != Args[Idx]) {
13320 Args[Idx] = Res.
get();
13330 if (
Result.isInvalid()) {
13341 IsParenListInit = !InitSeq.
steps().empty() &&
13353 CheckSelfReference(*
this, RealDecl, Init,
DirectInit);
13365 if (VDecl->
hasAttr<BlocksAttr>())
13379 Init->getBeginLoc()))
13380 FSI->markSafeWeakUse(Init);
13397 if (
Result.isInvalid()) {
13430 isa<InitListExpr>(Init)) {
13431 const Expr *Culprit;
13432 if (!Init->isConstantInitializer(
Context,
false, &Culprit)) {
13434 diag::ext_aggregate_init_not_constant)
13439 if (
auto *E = dyn_cast<ExprWithCleanups>(Init))
13440 if (
auto *BE = dyn_cast<BlockExpr>(E->getSubExpr()->
IgnoreParens()))
13442 BE->getBlockDecl()->setCanAvoidCopyToHeap();
13477 << Init->getSourceRange();
13488 else if (Init->isValueDependent())
13490 else if (Init->isIntegerConstantExpr(
Context, &Loc))
13492 else if (Init->getType()->isScopedEnumeralType() &&
13493 Init->isCXX11ConstantExpr(
Context))
13495 else if (Init->isEvaluatable(
Context)) {
13498 Diag(Loc, diag::ext_in_class_initializer_non_constant)
13499 << Init->getSourceRange();
13503 Diag(Loc, diag::err_in_class_initializer_non_constant)
13504 << Init->getSourceRange();
13514 diag::ext_in_class_initializer_float_type_cxx11)
13515 << DclT << Init->getSourceRange();
13517 diag::note_in_class_initializer_float_type_cxx11)
13520 Diag(VDecl->
getLocation(), diag::ext_in_class_initializer_float_type)
13521 << DclT << Init->getSourceRange();
13523 if (!Init->isValueDependent() && !Init->isEvaluatable(
Context)) {
13524 Diag(Init->getExprLoc(), diag::err_in_class_initializer_non_constant)
13525 << Init->getSourceRange();
13532 Diag(VDecl->
getLocation(), diag::err_in_class_initializer_literal_type)
13533 << DclT << Init->getSourceRange()
13539 << DclT << Init->getSourceRange();
13570 QualType InitType = Init->getType();
13571 if (!InitType.
isNull() &&
13590 if (CXXDirectInit) {
13591 assert(
DirectInit &&
"Call-style initializer must be direct init.");
13602 DeclsToCheckForDeferredDiags.insert(VDecl);
13615 VarDecl *VD = dyn_cast<VarDecl>(D);
13619 if (
auto *DD = dyn_cast<DecompositionDecl>(D))
13620 for (
auto *BD : DD->bindings())
13621 BD->setInvalidDecl();
13635 diag::err_typecheck_decl_incomplete_type)) {
13642 diag::err_abstract_type_in_decl,
13657 if (
VarDecl *Var = dyn_cast<VarDecl>(RealDecl)) {
13661 if (isa<DecompositionDecl>(RealDecl)) {
13662 Diag(Var->getLocation(), diag::err_decomp_decl_requires_init) << Var;
13663 Var->setInvalidDecl();
13677 if (Var->isConstexpr() && !Var->isThisDeclarationADefinition() &&
13678 !Var->isThisDeclarationADemotedDefinition()) {
13679 if (Var->isStaticDataMember()) {
13684 Diag(Var->getLocation(),
13685 diag::err_constexpr_static_mem_var_requires_init)
13687 Var->setInvalidDecl();
13691 Diag(Var->getLocation(), diag::err_invalid_constexpr_var_decl);
13692 Var->setInvalidDecl();
13699 if (!Var->isInvalidDecl() &&
13701 Var->getStorageClass() !=
SC_Extern && !Var->getInit()) {
13702 bool HasConstExprDefaultConstructor =
false;
13703 if (
CXXRecordDecl *RD = Var->getType()->getAsCXXRecordDecl()) {
13704 for (
auto *Ctor : RD->ctors()) {
13705 if (Ctor->isConstexpr() && Ctor->getNumParams() == 0 &&
13706 Ctor->getMethodQualifiers().getAddressSpace() ==
13708 HasConstExprDefaultConstructor =
true;
13712 if (!HasConstExprDefaultConstructor) {
13713 Diag(Var->getLocation(), diag::err_opencl_constant_no_init);
13714 Var->setInvalidDecl();
13719 if (!Var->isInvalidDecl() && RealDecl->
hasAttr<LoaderUninitializedAttr>()) {
13720 if (Var->getStorageClass() ==
SC_Extern) {
13721 Diag(Var->getLocation(), diag::err_loader_uninitialized_extern_decl)
13723 Var->setInvalidDecl();
13727 diag::err_typecheck_decl_incomplete_type)) {
13728 Var->setInvalidDecl();
13731 if (
CXXRecordDecl *RD = Var->getType()->getAsCXXRecordDecl()) {
13732 if (!RD->hasTrivialDefaultConstructor()) {
13733 Diag(Var->getLocation(), diag::err_loader_uninitialized_trivial_ctor);
13734 Var->setInvalidDecl();
13744 Var->getType().hasNonTrivialToPrimitiveDefaultInitializeCUnion())
13751 if (!Var->isStaticDataMember() || !Var->getAnyInitializer())
13767 !Var->hasLinkage() && !Var->isInvalidDecl() &&
13769 diag::err_typecheck_decl_incomplete_type))
13770 Var->setInvalidDecl();
13775 diag::err_abstract_type_in_decl,
13777 Var->setInvalidDecl();
13780 Diag(Var->getLocation(), diag::warn_private_extern);
13781 Diag(Var->getLocation(), diag::note_private_extern);
13785 !Var->isInvalidDecl())
13796 if (!Var->isInvalidDecl()) {
13800 Var->getLocation(), ArrayT->getElementType(),
13801 diag::err_array_incomplete_or_sizeless_type))
13802 Var->setInvalidDecl();
13803 }
else if (Var->getStorageClass() ==
SC_Static) {
13813 if (Var->isFirstDecl())
13815 diag::ext_typecheck_decl_incomplete_type);
13820 if (!Var->isInvalidDecl())
13828 if (Var->isConstexpr())
13829 Diag(Var->getLocation(), diag::err_constexpr_var_requires_const_init)
13832 Diag(Var->getLocation(),
13833 diag::err_typecheck_incomplete_array_needs_initializer);
13834 Var->setInvalidDecl();
13841 Diag(Var->getLocation(), diag::err_reference_var_requires_init)
13842 << Var <<
SourceRange(Var->getLocation(), Var->getLocation());
13851 if (Var->isInvalidDecl())
13854 if (!Var->hasAttr<AliasAttr>()) {
13857 diag::err_typecheck_decl_incomplete_type)) {
13858 Var->setInvalidDecl();
13867 diag::err_abstract_type_in_decl,
13869 Var->setInvalidDecl();
13884 if (
const RecordType *Record
13890 if (!CXXRecord->isPOD())
13924 }
else if (Init.isInvalid()) {
13942 VarDecl *VD = dyn_cast<VarDecl>(D);
14001 const char *PrevSpec;
14067 !isa<VarTemplatePartialSpecializationDecl>(var) &&
14069 !
getDiagnostics().isIgnored(diag::warn_missing_variable_declarations,
14077 Diag(var->
getLocation(), diag::warn_missing_variable_declarations) << var;
14084 std::optional<bool> CacheHasConstInit;
14085 const Expr *CacheCulprit =
nullptr;
14086 auto checkConstInit = [&]()
mutable {
14087 if (!CacheHasConstInit)
14090 return *CacheHasConstInit;
14102 if (!checkConstInit()) {
14117 isa<InitListExpr>(var->
getInit())) {
14119 unsigned NumInits = ILE->getNumInits();
14121 for (
unsigned I = 0; I < NumInits; ++I) {
14122 const auto *Init = ILE->getInit(I);
14125 const auto *SL = dyn_cast<StringLiteral>(Init->IgnoreImpCasts());
14129 unsigned NumConcat = SL->getNumConcatenated();
14133 if (NumConcat == 2 && !SL->getBeginLoc().isMacroID()) {
14134 bool OnlyOneMissingComma =
true;
14135 for (
unsigned J = I + 1; J < NumInits; ++J) {
14136 const auto *Init = ILE->getInit(J);
14139 const auto *SLJ = dyn_cast<StringLiteral>(Init->IgnoreImpCasts());
14140 if (!SLJ || SLJ->getNumConcatenated() > 1) {
14141 OnlyOneMissingComma =
false;
14146 if (OnlyOneMissingComma) {
14148 for (
unsigned i = 0; i < NumConcat - 1; ++i)
14152 Diag(SL->getStrTokenLoc(1),
14153 diag::warn_concatenated_literal_array_init)
14155 Diag(SL->getBeginLoc(),
14156 diag::note_concatenated_string_literal_silence);
14167 if (var->
hasAttr<BlocksAttr>())
14174 bool HasConstInit =
true;
14178 !Init->isValueDependent() &&
14192 HasConstInit = checkConstInit();
14196 if (HasConstInit) {
14199 }
else if (CacheCulprit) {
14200 Notes.emplace_back(CacheCulprit->
getExprLoc(),
14201 PDiag(diag::note_invalid_subexpr_in_const_expr));
14209 if (HasConstInit) {
14215 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
14216 diag::note_invalid_subexpr_in_const_expr) {
14217 DiagLoc = Notes[0].first;
14220 Diag(DiagLoc, diag::err_constexpr_var_requires_const_init)
14221 << var << Init->getSourceRange();
14222 for (
unsigned I = 0,
N = Notes.size(); I !=
N; ++I)
14223 Diag(Notes[I].first, Notes[I].second);
14224 }
else if (GlobalStorage && var->
hasAttr<ConstInitAttr>()) {
14227 << Init->getSourceRange();
14230 for (
auto &it : Notes)
14231 Diag(it.first, it.second);
14232 }
else if (IsGlobal &&
14243 if (!checkConstInit())
14245 << Init->getSourceRange();
14262 }
else if (var->
hasInit() && HasConstInit) {
14269 if (
const SectionAttr *SA = var->
getAttr<SectionAttr>()) {
14273 }
else if (Stack->CurrentValue) {
14275 auto SectionName = Stack->CurrentValue->getString();
14277 Stack->CurrentPragmaLocation,
14278 SectionAttr::Declspec_allocate));
14301 if (!type->isDependentType())
14311 if (
auto *DD = dyn_cast<DecompositionDecl>(var))
14324 !FD->
hasAttr<DLLExportStaticLocalAttr>() &&
14325 !FD->
hasAttr<DLLImportStaticLocalAttr>()) {
14335 NewAttr->setInherited(
true);
14337 }
else if (
Attr *A = FD->
getAttr<DLLExportStaticLocalAttr>()) {
14338 auto *NewAttr = DLLExportAttr::CreateImplicit(
getASTContext(), *A);
14339 NewAttr->setInherited(
true);
14344 if (!FD->
hasAttr<DLLExportAttr>())
14347 }
else if (
Attr *A = FD->
getAttr<DLLImportStaticLocalAttr>()) {
14348 auto *NewAttr = DLLImportAttr::CreateImplicit(
getASTContext(), *A);
14349 NewAttr->setInherited(
true);
14380 VarDecl *VD = dyn_cast_or_null<VarDecl>(ThisDecl);
14388 VD->
addAttr(PragmaClangBSSSectionAttr::CreateImplicit(
14392 VD->
addAttr(PragmaClangDataSectionAttr::CreateImplicit(
14396 VD->
addAttr(PragmaClangRodataSectionAttr::CreateImplicit(
14400 VD->
addAttr(PragmaClangRelroSectionAttr::CreateImplicit(
14405 if (
auto *DD = dyn_cast<DecompositionDecl>(ThisDecl)) {
14406 for (
auto *BD : DD->bindings()) {
14431 if (
const auto *IA = dyn_cast_or_null<DLLImportAttr>(DLLAttr)) {
14438 bool IsClassTemplateMember =
14440 Context->getDescribedClassTemplate();
14443 IsClassTemplateMember
14444 ? diag::warn_attribute_dllimport_static_field_definition
14445 : diag::err_attribute_dllimport_static_field_definition);
14446 Diag(IA->getLocation(), diag::note_attribute);
14447 if (!IsClassTemplateMember)
14475 if (RetainAttr *
Attr = VD->
getAttr<RetainAttr>()) {
14490 if (VD->
isFileVarDecl() && !isa<VarTemplatePartialSpecializationDecl>(VD))
14495 if (!VD->
hasAttr<TypeTagForDatatypeAttr>() ||
14499 for (
const auto *I : ThisDecl->
specific_attrs<TypeTagForDatatypeAttr>()) {
14501 if (!MagicValueExpr) {
14504 std::optional<llvm::APSInt> MagicValueInt;
14506 Diag(I->getRange().getBegin(),
14507 diag::err_type_tag_for_datatype_not_ice)
14511 if (MagicValueInt->getActiveBits() > 64) {
14512 Diag(I->getRange().getBegin(),
14513 diag::err_type_tag_for_datatype_too_large)
14517 uint64_t MagicValue = MagicValueInt->getZExtValue();
14520 I->getMatchingCType(),
14521 I->getLayoutCompatible(),
14522 I->getMustBeNull());
14527 auto *VD = dyn_cast<VarDecl>(DD);
14528 return VD && !VD->getType()->hasAutoForTrailingReturnType();
14540 bool DiagnosedMultipleDecomps =
false;
14542 bool DiagnosedNonDeducedAuto =
false;
14544 for (
unsigned i = 0, e = Group.size(); i != e; ++i) {
14545 if (
Decl *D = Group[i]) {
14548 if (
auto *VD = dyn_cast<VarDecl>(D);
14549 LangOpts.OpenMP && VD && VD->hasAttr<OMPDeclareTargetDeclAttr>() &&
14550 VD->hasGlobalStorage())
14554 if (
auto *DD = dyn_cast<DeclaratorDecl>(D)) {
14555 if (!FirstDeclaratorInGroup)
14556 FirstDeclaratorInGroup = DD;
14557 if (!FirstDecompDeclaratorInGroup)
14558 FirstDecompDeclaratorInGroup = dyn_cast<DecompositionDecl>(D);
14561 FirstNonDeducedAutoInGroup = DD;
14563 if (FirstDeclaratorInGroup != DD) {
14566 if (FirstDecompDeclaratorInGroup && !DiagnosedMultipleDecomps) {
14568 diag::err_decomp_decl_not_alone)
14570 << DD->getSourceRange();
14571 DiagnosedMultipleDecomps =
true;
14577 if (FirstNonDeducedAutoInGroup && !DiagnosedNonDeducedAuto) {
14579 diag::err_auto_non_deduced_not_alone)
14580 << FirstNonDeducedAutoInGroup->
getType()
14583 << DD->getSourceRange();
14584 DiagnosedNonDeducedAuto =
true;
14589 Decls.push_back(D);
14596 if (FirstDeclaratorInGroup && !Tag->hasNameForLinkage() &&
14612 if (Group.size() > 1) {
14614 VarDecl *DeducedDecl =
nullptr;
14615 for (
unsigned i = 0, e = Group.size(); i != e; ++i) {
14616 VarDecl *D = dyn_cast<VarDecl>(Group[i]);
14620 if (!DT || DT->getDeducedType().isNull())
14623 Deduced = DT->getDeducedType();
14626 auto *AT = dyn_cast<AutoType>(DT);
14628 diag::err_auto_different_deductions)
14629 << (AT ? (
unsigned)AT->getKeyword() : 3) << Deduced
14630 << DeducedDecl->
getDeclName() << DT->getDeducedType()
14654 if (Group.empty() || !Group[0])
14658 Group[0]->getLocation()) &&
14660 Group[0]->getLocation()))
14663 if (Group.size() >= 2) {
14671 Decl *MaybeTagDecl = Group[0];
14672 if (MaybeTagDecl && isa<TagDecl>(MaybeTagDecl)) {
14673 Group = Group.slice(1);
14738 : diag::warn_deprecated_register)
14746 diag::err_invalid_storage_class_in_func_decl);
14758 << 0 <<
static_cast<int>(D.
getDeclSpec().getConstexprSpecifier());
14779 PrevDecl =
nullptr;
14780 }
else if (S->isDeclScope(PrevDecl)) {
14802 assert(S->isFunctionPrototypeScope());
14803 assert(S->getFunctionPrototypeDepth() >= 1);
14805 S->getNextFunctionPrototypeIndex());
14819 if (New->
hasAttr<BlocksAttr>()) {
14840 Param->setImplicit();
14853 Diag(
Parameter->getLocation(), diag::warn_unused_parameter)
14861 if (
LangOpts.NumLargeByValueCopy == 0)
14868 if (Size >
LangOpts.NumLargeByValueCopy)
14876 if (T->isDependentType() || !T.isPODType(
Context))
14879 if (Size >
LangOpts.NumLargeByValueCopy)
14892 T->isObjCLifetimeType()) {
14899 if (T->isArrayType()) {
14900 if (!T.isConstQualified()) {
14904 NameLoc, diag::err_arc_array_param_no_ownership, T,
false));
14906 Diag(NameLoc, diag::err_arc_array_param_no_ownership)
14911 lifetime = T->getObjCARCImplicitLifetime();
14918 TSInfo, SC,
nullptr);
14925 LSI->LocalPacks.push_back(New);
14934 if (T->isObjCObjectType()) {
14938 diag::err_object_cannot_be_passed_returned_by_value) << 1 << T
14955 !(T->isFunctionPointerType() &&
14957 Diag(NameLoc, diag::err_arg_with_address_space);
14985 for (
int i = FTI.
NumParams; i != 0; ) {
14990 llvm::raw_svector_ostream(Code)
15001 const char* PrevSpec;
15035 ParentScope, D, TemplateParameterLists, Bases);
15041 if (!Bases.empty())
15057 if (Prev->getLexicalDeclContext()->isFunctionOrMethod())
15060 PossiblePrototype = Prev;
15078 if (isa<CXXMethodDecl>(FD))
15084 if (II->isStr(
"main") || II->isStr(
"efi_main"))
15100 if (FD->
hasAttr<OpenCLKernelAttr>())
15154 Definition->getDescribedFunctionTemplate() ||
15155 Definition->getNumTemplateParameterLists())) {
15158 if (
auto *TD =
Definition->getDescribedFunctionTemplate())
15171 Diag(
Definition->getLocation(), diag::note_previous_definition);
15181 LSI->
Lambda = LambdaClass;
15199 for (
const auto &
C : LambdaClass->
captures()) {
15200 if (
C.capturesVariable()) {
15204 const bool ByRef =
C.getCaptureKind() ==
LCK_ByRef;
15206 true,
C.getLocation(),
15207 C.isPackExpansion()
15209 I->getType(),
false);
15211 }
else if (
C.capturesThis()) {
15236 FD = FunTmpl->getTemplatedDecl();
15263 if (
const auto *
Attr = FD->
getAttr<AliasAttr>()) {
15268 if (
const auto *
Attr = FD->
getAttr<IFuncAttr>()) {
15273 if (
const auto *
Attr = FD->
getAttr<TargetVersionAttr>()) {
15275 !
Attr->isDefaultVersion()) {
15284 if (
auto *Ctor = dyn_cast<CXXConstructorDecl>(FD)) {
15286 Ctor->isDefaultConstructor() &&
15321 "There should be an active template instantiation on the stack "
15322 "when instantiating a generic lambda!");
15347 diag::err_func_def_incomplete_result) ||
15349 diag::err_abstract_type_in_decl,
15365 auto *NonParmDecl = dyn_cast<NamedDecl>(NPD);
15368 assert(!isa<ParmVarDecl>(NonParmDecl) &&
15369 "parameters should not be in newly created FD yet");
15372 if (NonParmDecl->getDeclName())
15377 if (
auto *ED = dyn_cast<EnumDecl>(NonParmDecl)) {
15378 for (
auto *EI : ED->enumerators())
15386 Param->setOwningFunction(FD);
15389 if (Param->getIdentifier() && FnBodyScope) {
15418 assert(!FD->
hasAttr<DLLExportAttr>());
15419 Diag(FD->
getLocation(), diag::err_attribute_dllimport_function_definition);
15449 for (
unsigned I = 0, E =
Scope->Returns.size(); I != E; ++I) {
15450 if (
const VarDecl *NRVOCandidate = Returns[I]->getNRVOCandidate()) {
15451 if (!NRVOCandidate->isNRVOVariable())
15470 Outer.Fun.hasTrailingReturnType()) {
15488 if (FD->isConstexpr())
15493 if (FD->getReturnType()->getContainedDeducedType())
15503 FD->setHasSkippedBody();
15525 bool IsLambda =
false;
15529 llvm::DenseMap<const BlockDecl *, bool> EscapeInfo;
15531 auto IsOrNestedInEscapingBlock = [&](
const BlockDecl *BD) {
15532 if (EscapeInfo.count(BD))
15533 return EscapeInfo[BD];
15545 return EscapeInfo[BD] = R;
15550 for (
const std::pair<SourceLocation, const BlockDecl *> &
P :
15552 if (IsOrNestedInEscapingBlock(
P.second))
15553 S.
Diag(
P.first, diag::warn_implicitly_retains_self)
15558 bool IsInstantiation) {
15593 Expr *Dummy =
nullptr;
15604 if (LSI->HasImplicitReturnType) {
15611 LSI->ReturnType.isNull() ?
Context.
VoidTy : LSI->ReturnType;
15616 Proto->getExtProtoInfo()));
15643 dyn_cast<CXXDestructorDecl>(FD))
15663 if (PossiblePrototype) {
15667 TypeLoc TL = TI->getTypeLoc();
15670 diag::note_declaration_not_a_prototype)
15673 FTL.getRParenLoc(),
"void")
15680 std::pair<FileID, unsigned> LocInfo =
SM.getDecomposedLoc(Loc);
15681 if (LocInfo.first.isInvalid())
15685 StringRef Buffer =
SM.getBufferData(LocInfo.first, &
Invalid);
15689 if (LocInfo.second > Buffer.size())
15692 const char *LexStart = Buffer.data() + LocInfo.second;
15693 StringRef StartTok(LexStart, Buffer.size() - LocInfo.second);
15695 return StartTok.consume_front(
"const") &&
15697 StartTok.startswith(
"/*") || StartTok.startswith(
"//"));
15700 auto findBeginLoc = [&]() {
15716 diag::note_static_for_internal_linkage)
15727 if (!PossiblePrototype)
15773 if (PossiblePrototype)
15775 diag::warn_non_prototype_changes_behavior)
15782 if (
const auto *CmpndBody = dyn_cast<CompoundStmt>(Body))
15783 if (!CmpndBody->body_empty())
15784 Diag(CmpndBody->body_front()->getBeginLoc(),
15785 diag::warn_dispatch_body_ignored);
15787 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
15813 "Function parsing confused");
15814 }
else if (
ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(dcl)) {
15826 << MD->getSelector().getAsString();
15831 bool isDesignated =
15832 MD->isDesignatedInitializerForTheInterface(&InitMethod);
15833 assert(isDesignated && InitMethod);
15834 (void)isDesignated;
15837 auto IFace = MD->getClassInterface();
15840 auto SuperD = IFace->getSuperClass();
15850 diag::warn_objc_designated_init_missing_super_call);
15852 diag::note_objc_designated_init_marked_here);
15860 diag::warn_objc_secondary_init_missing_init_call);
15876 "This should only be set for ObjC methods, which should have been "
15877 "handled in the block above.");
15884 if (FD && isa<CXXConstructorDecl>(FD) && isa<CXXTryStmt>(Body))
15892 if (!Destructor->getParent()->isDependentType())
15896 Destructor->getParent());
15909 ActivePolicy = &WP;
15916 if (FD && FD->
hasAttr<NakedAttr>()) {
15920 bool RegisterVariables =
false;
15921 if (
auto *DS = dyn_cast<DeclStmt>(S)) {
15922 for (
const auto *
Decl : DS->decls()) {
15923 if (
const auto *Var = dyn_cast<VarDecl>(
Decl)) {
15924 RegisterVariables =
15925 Var->hasAttr<AsmLabelAttr>() && !Var->hasInit();
15926 if (!RegisterVariables)
15931 if (RegisterVariables)
15933 if (!isa<AsmStmt>(S) && !isa<NullStmt>(S)) {
15934 Diag(S->getBeginLoc(), diag::err_non_asm_stmt_in_naked_function);
15935 Diag(FD->
getAttr<NakedAttr>()->getLocation(), diag::note_attribute);
15944 "Leftover temporaries in function");
15945 assert(!Cleanup.exprNeedsCleanups() &&
15946 "Unaccounted cleanups in function");
15948 "Leftover expressions for odr-use checking");
15954 if (!IsInstantiation)
15971 DeclsToCheckForDeferredDiags.insert(FD);
15986 D = TD->getTemplatedDecl();
15989 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(D))
15990 if (Method->isStatic())
16000 "Implicit function declarations aren't allowed in this language mode");
16007 Scope *BlockScope = S;
16015 Scope *ContextScope = BlockScope;
16019 ContextScope = ContextScope->
getParent();
16035 if (!isa<FunctionDecl>(ExternCPrev) ||
16037 cast<FunctionDecl>(ExternCPrev)->getType(),
16039 Diag(Loc, diag::ext_use_out_of_scope_declaration)
16042 return ExternCPrev;
16048 if (II.
getName().startswith(
"__builtin_"))
16049 diag_id = diag::warn_builtin_unknown;
16052 diag_id = diag::ext_implicit_function_decl_c99;
16054 diag_id = diag::warn_implicit_function_decl;
16062 if (S && !ExternCPrev &&
16069 Diag(Loc, diag_id) << &II;
16085 return ExternCPrev;
16095 assert(!Error &&
"Error setting up implicit decl!");
16143 std::optional<unsigned> AlignmentParam;
16144 bool IsNothrow =
false;
16156 if (!IsNothrow && !FD->
hasAttr<ReturnsNonNullAttr>() &&
16174 if (!FD->
hasAttr<AllocSizeAttr>()) {
16175 FD->
addAttr(AllocSizeAttr::CreateImplicit(
16186 if (AlignmentParam && !FD->
hasAttr<AllocAlignAttr>()) {
16187 FD->
addAttr(AllocAlignAttr::CreateImplicit(
16220 unsigned FormatIdx;
16223 if (!FD->
hasAttr<FormatAttr>()) {
16224 const char *fmt =
"printf";
16226 if (FormatIdx < NumParams &&
16232 HasVAListArg ? 0 : FormatIdx+2,
16238 if (!FD->
hasAttr<FormatAttr>())
16242 HasVAListArg ? 0 : FormatIdx+2,
16248 if (!FD->
hasAttr<CallbackAttr>() &&
16250 FD->
addAttr(CallbackAttr::CreateImplicit(
16256 bool NoExceptions =
16258 bool ConstWithoutErrnoAndExceptions =
16260 bool ConstWithoutExceptions =
16262 if (!FD->
hasAttr<ConstAttr>() &&
16263 (ConstWithoutErrnoAndExceptions || ConstWithoutExceptions) &&
16264 (!ConstWithoutErrnoAndExceptions ||
16266 (!ConstWithoutExceptions || NoExceptions))
16273 if ((Trip.isGNUEnvironment() || Trip.isOSMSVCRT()) &&
16275 switch (BuiltinID) {
16276 case Builtin::BI__builtin_fma:
16277 case Builtin::BI__builtin_fmaf:
16278 case Builtin::BI__builtin_fmal:
16279 case Builtin::BIfma:
16280 case Builtin::BIfmaf:
16281 case Builtin::BIfmal:
16290 !FD->
hasAttr<ReturnsTwiceAttr>())
16300 !FD->
hasAttr<CUDADeviceAttr>() && !FD->
hasAttr<CUDAHostAttr>()) {
16312 switch (BuiltinID) {
16313 case Builtin::BImemalign:
16314 case Builtin::BIaligned_alloc:
16315 if (!FD->
hasAttr<AllocAlignAttr>())
16324 switch (BuiltinID) {
16325 case Builtin::BIcalloc:
16326 FD->
addAttr(AllocSizeAttr::CreateImplicit(
16329 case Builtin::BImemalign:
16330 case Builtin::BIaligned_alloc:
16331 case Builtin::BIrealloc:
16335 case Builtin::BImalloc:
16344 switch (BuiltinID) {
16345 case Builtin::BIaddressof:
16346 case Builtin::BI__addressof:
16347 case Builtin::BI__builtin_addressof:
16348 case Builtin::BIas_const:
16349 case Builtin::BIforward:
16350 case Builtin::BIforward_like:
16351 case Builtin::BImove:
16352 case Builtin::BImove_if_noexcept:
16354 !
P->hasAttr<LifetimeBoundAttr>())
16371 if (!FPT || FPT->getExceptionSpecType() ==
EST_None)
16388 if (Name->isStr(
"asprintf") || Name->isStr(
"vasprintf")) {
16391 if (!FD->
hasAttr<FormatAttr>())
16394 Name->isStr(
"vasprintf") ? 0 : 3,
16398 if (Name->isStr(
"__CFStringMakeConstantString")) {
16401 if (!FD->
hasAttr<FormatArgAttr>())
16409 assert(D.
getIdentifier() &&
"Wrong callback for declspec without declarator");
16410 assert(!T.isNull() &&
"GetTypeForDeclarator() returned null type");
16413 assert(D.
isInvalidType() &&
"no declarator info for valid type");
16468 if (T->isDependentType())
16474 if (BT->isInteger())
16477 if (T->isBitIntType())
16480 return Diag(UnderlyingLoc, diag::err_enum_invalid_underlying) << T;
16486 QualType EnumUnderlyingTy,
bool IsFixed,
16488 if (IsScoped != Prev->
isScoped()) {
16489 Diag(EnumLoc, diag::err_enum_redeclare_scoped_mismatch)
16495 if (IsFixed && Prev->
isFixed()) {
16501 Diag(EnumLoc, diag::err_enum_redeclare_type_mismatch)
16507 }
else if (IsFixed != Prev->
isFixed()) {
16508 Diag(EnumLoc, diag::err_enum_redeclare_fixed_mismatch)
16524 case TTK_Struct:
return 0;
16525 case TTK_Interface:
return 1;
16526 case TTK_Class:
return 2;
16527 default: llvm_unreachable(
"Invalid tag kind for redecl diagnostic!");
16537 return Tag == TTK_Struct || Tag == TTK_Class || Tag == TTK_Interface;
16542 if (isa<TypedefDecl>(PrevDecl))
16544 else if (isa<TypeAliasDecl>(PrevDecl))
16546 else if (isa<ClassTemplateDecl>(PrevDecl))
16548 else if (isa<TypeAliasTemplateDecl>(PrevDecl))
16550 else if (isa<TemplateTemplateParmDecl>(PrevDecl))
16554 case TTK_Interface:
16562 llvm_unreachable(
"invalid TTK");
16570 TagTypeKind NewTag,
bool isDefinition,
16586 TagTypeKind OldTag =
Previous->getTagKind();
16587 if (OldTag != NewTag &&
16605 if (IsIgnoredLoc(NewTagLoc))
16608 auto IsIgnored = [&](
const TagDecl *Tag) {
16609 return IsIgnoredLoc(Tag->getLocation());
16620 isTemplate = Record->getDescribedClassTemplate();
16623 if (OldTag != NewTag) {
16626 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
16634 if (isDefinition) {
16642 bool previousMismatch =
false;
16644 if (I->getTagKind() != NewTag) {
16649 if (!previousMismatch) {
16650 previousMismatch =
true;
16651 Diag(NewTagLoc, diag::warn_struct_class_previous_tag_mismatch)
16655 Diag(I->getInnerLocStart(), diag::note_struct_class_suggestion)
16658 TypeWithKeyword::getTagTypeKindName(NewTag));
16668 if (PrevDef && IsIgnored(PrevDef))
16672 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
16679 Diag(NewTagLoc, diag::note_struct_class_suggestion)
16682 TypeWithKeyword::getTagTypeKindName(Redecl->
getTagKind()));
16709 if (!Namespace || Namespace->isAnonymousNamespace())
16712 Namespaces.push_back(II);
16715 if (Lookup == Namespace)
16722 llvm::raw_svector_ostream OS(Insertion);
16725 std::reverse(Namespaces.begin(), Namespaces.end());
16726 for (
auto *II : Namespaces)
16727 OS << II->getName() <<
"::";
16740 if (OldDC->
Equals(NewDC))
16769 bool ScopedEnumUsesClassTag,
TypeResult UnderlyingType,
16770 bool IsTypeSpecifier,
bool IsTemplateParamOrArg,
16775 "Nameless record must be a definition!");
16776 assert(TemplateParameterLists.size() == 0 || TUK !=
TUK_Reference);
16779 TagTypeKind Kind = TypeWithKeyword::getTagTypeKindForTypeSpec(TagSpec);
16780 bool ScopedEnum = ScopedEnumKWLoc.
isValid();
16783 bool isMemberSpecialization =
false;
16789 if (TemplateParameterLists.size() > 0 ||
16793 KWLoc, NameLoc, SS,
nullptr, TemplateParameterLists,
16795 if (Kind == TTK_Enum) {
16796 Diag(KWLoc, diag::err_enum_template);
16800 if (TemplateParams->size() > 0) {
16809 S, TagSpec, TUK, KWLoc, SS, Name, NameLoc, Attrs, TemplateParams,
16810 AS, ModulePrivateLoc,
16812 TemplateParameterLists.data(), SkipBody);
16816 Diag(TemplateParams->getTemplateLoc(), diag::err_template_tag_noparams)
16817 << TypeWithKeyword::getTagTypeKindName(Kind) << Name;
16818 isMemberSpecialization =
true;
16822 if (!TemplateParameterLists.empty() && isMemberSpecialization &&
16830 llvm::PointerUnion<const Type*, TypeSourceInfo*> EnumUnderlying;
16831 bool IsFixed = !UnderlyingType.
isUnset() || ScopedEnum;
16833 if (Kind == TTK_Enum) {
16834 if (UnderlyingType.
isInvalid() || (!UnderlyingType.
get() && ScopedEnum)) {
16838 }
else if (UnderlyingType.
get()) {
16843 EnumUnderlying = TI;
16865 bool isStdBadAlloc =
false;
16866 bool isStdAlignValT =
false;
16875 auto createTagFromNewDecl = [&]() ->
TagDecl * {
16883 if (Kind == TTK_Enum) {
16885 ScopedEnum, ScopedEnumUsesClassTag, IsFixed);
16889 if (EnumUnderlying) {
16905 if (
RecordDecl *RD = dyn_cast<RecordDecl>(New)) {
16931 goto CreateNewDecl;
16939 IsDependent =
true;
16968 if (
Previous.wasNotFoundInCurrentInstantiation() &&
16970 IsDependent =
true;
16975 Diag(NameLoc, diag::err_not_tag_in_scope)
16976 << Kind << Name << DC << SS.
getRange();
16979 goto CreateNewDecl;
17027 bool FriendSawTagOutsideEnclosingNamespace =
false;
17034 FriendSawTagOutsideEnclosingNamespace =
true;
17043 if (
Previous.isSingleResult() && FriendSawTagOutsideEnclosingNamespace) {
17045 Diag(NameLoc, diag::ext_friend_tag_redecl_outside_namespace)
17059 while (isa<RecordDecl, EnumDecl, ObjCContainerDecl>(SearchDC))
17065 while (isa<ObjCContainerDecl>(SearchDC))
17071 while (isa<ObjCContainerDecl>(SearchDC))
17076 Previous.getFoundDecl()->isTemplateParameter()) {
17085 if (Name->isStr(
"bad_alloc")) {
17087 isStdBadAlloc =
true;
17094 }
else if (Name->isStr(
"align_val_t")) {
17095 isStdAlignValT =
true;
17107 if (
Invalid)
goto CreateNewDecl;
17190 if (
const TagType *TT = TD->getUnderlyingType()->getAs<TagType>()) {
17191 TagDecl *Tag = TT->getDecl();
17192 if (Tag->getDeclName() == Name &&
17193 Tag->getDeclContext()->getRedeclContext()
17194 ->Equals(TD->getDeclContext()->getRedeclContext())) {
17207 if (
auto *Shadow = dyn_cast<UsingShadowDecl>(DirectPrevDecl)) {
17208 auto *OldTag = dyn_cast<TagDecl>(PrevDecl);
17210 isDeclInScope(Shadow, SearchDC, S, isMemberSpecialization) &&
17212 *
this, OldTag->getDeclContext(), SearchDC))) {
17213 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
17214 Diag(Shadow->getTargetDecl()->getLocation(),
17215 diag::note_using_decl_target);
17216 Diag(Shadow->getIntroducer()->getLocation(), diag::note_using_decl)
17220 goto CreateNewDecl;
17224 if (
TagDecl *PrevTagDecl = dyn_cast<TagDecl>(PrevDecl)) {
17230 SS.
isNotEmpty() || isMemberSpecialization)) {
17236 bool SafeToContinue
17237 = (PrevTagDecl->getTagKind() != TTK_Enum &&
17239 if (SafeToContinue)
17240 Diag(KWLoc, diag::err_use_with_wrong_tag)
17243 PrevTagDecl->getKindName());
17245 Diag(KWLoc, diag::err_use_with_wrong_tag) << Name;
17246 Diag(PrevTagDecl->getLocation(), diag::note_previous_use);
17248 if (SafeToContinue)
17249 Kind = PrevTagDecl->getTagKind();
17258 if (Kind == TTK_Enum && PrevTagDecl->getTagKind() == TTK_Enum) {
17261 return PrevTagDecl;
17265 EnumUnderlyingTy = TI->getType().getUnqualifiedType();
17266 else if (
const Type *T = EnumUnderlying.dyn_cast<
const Type*>())
17267 EnumUnderlyingTy =
QualType(T, 0);
17273 ScopedEnum, EnumUnderlyingTy,
17274 IsFixed, PrevEnum))
17283 S->isDeclScope(PrevDecl)) {
17284 Diag(NameLoc, diag::ext_member_redeclared);
17285 Diag(PrevTagDecl->getLocation(), diag::note_previous_declaration);
17292 if (!Attrs.
empty()) {
17296 (PrevTagDecl->getFriendObjectKind() ==
17309 return PrevTagDecl;
17314 return PrevTagDecl;
17320 if (
NamedDecl *Def = PrevTagDecl->getDefinition()) {
17324 bool IsExplicitSpecializationAfterInstantiation =
false;
17325 if (isMemberSpecialization) {
17327 IsExplicitSpecializationAfterInstantiation =
17328 RD->getTemplateSpecializationKind() !=
17330 else if (
EnumDecl *ED = dyn_cast<EnumDecl>(Def))
17331 IsExplicitSpecializationAfterInstantiation =
17332 ED->getTemplateSpecializationKind() !=
17352 SkipBody->
New = createTagFromNewDecl();
17362 }
else if (!IsExplicitSpecializationAfterInstantiation) {
17366 Diag(NameLoc, diag::warn_redefinition_in_param_list) << Name;
17368 Diag(NameLoc, diag::err_redefinition) << Name;
17370 NameLoc.
isValid() ? NameLoc : KWLoc);
17382 if (TD->isBeingDefined()) {
17383 Diag(NameLoc, diag::err_nested_redefinition) << Name;
17384 Diag(PrevTagDecl->getLocation(),
17385 diag::note_previous_definition);
17400 SearchDC = PrevTagDecl->getDeclContext();
17428 Diag(NameLoc, diag::err_tag_reference_non_tag) << PrevDecl << NTK
17435 SS.
isNotEmpty() || isMemberSpecialization)) {
17441 Diag(NameLoc, diag::err_tag_reference_conflict) << NTK;
17447 }
else if (
TypedefNameDecl *TND = dyn_cast<TypedefNameDecl>(PrevDecl)) {
17449 if (isa<TypeAliasDecl>(PrevDecl)) Kind = 1;
17450 Diag(NameLoc, diag::err_tag_definition_of_typedef)
17451 << Name << Kind << TND->getUnderlyingType();
17459 Diag(NameLoc, diag::err_redefinition_different_kind) << Name;
17487 if (Kind == TTK_Enum) {
17491 cast_or_null<EnumDecl>(PrevDecl), ScopedEnum,
17492 ScopedEnumUsesClassTag, IsFixed);
17500 if (IsFixed && cast<EnumDecl>(New)->isFixed()) {
17504 else if (PrevDecl && (Def = cast<EnumDecl>(PrevDecl)->
getDefinition())) {
17505 Diag(Loc, diag::ext_forward_ref_enum_def)
17509 unsigned DiagID = diag::ext_forward_ref_enum;
17511 DiagID = diag::ext_ms_forward_ref_enum;
17513 DiagID = diag::err_forward_ref_enum;
17518 if (EnumUnderlying) {
17528 assert(ED->
isComplete() &&
"enum with type should be complete");
17538 cast_or_null<CXXRecordDecl>(PrevDecl));
17544 cast_or_null<RecordDecl>(PrevDecl));
17554 (IsTypeSpecifier || IsTemplateParamOrArg) && TUK ==
TUK_Definition) {
17574 isMemberSpecialization))
17578 if (TemplateParameterLists.size() > 0) {
17586 if (
RecordDecl *RD = dyn_cast<RecordDecl>(New)) {
17602 if (ModulePrivateLoc.
isValid()) {
17603 if (isMemberSpecialization)
17622 if ((Name || Kind == TTK_Enum) &&
17628 Diag(Loc, diag::err_type_defined_in_param_type)
17632 }
else if (!PrevDecl) {
17693 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(New))
17708 if (
auto RD = dyn_cast<RecordDecl>(New))
17711 }
else if (SkipBody && SkipBody->
ShouldSkip) {
17743 "The next DeclContext should be lexically contained in the current one.");
17749 bool IsFinalSpelledSealed,
17757 if (!Record->getIdentifier())
17761 Record->markAbstract();
17764 Record->addAttr(FinalAttr::Create(
Context, FinalLoc,
17765 IsFinalSpelledSealed
17766 ? FinalAttr::Keyword_sealed
17767 : FinalAttr::Keyword_final));
17776 Record->getLocation(), Record->getIdentifier(),
17786 "Broken injected-class-name");
17793 Tag->setBraceRange(BraceRange);
17796 if (Tag->isBeingDefined()) {
17797 assert(Tag->isInvalidDecl() &&
"We should already have completed it");
17798 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
17802 if (
auto *RD = dyn_cast<CXXRecordDecl>(Tag)) {
17804 if (RD->
hasAttr<SYCLSpecialClassAttr>()) {
17806 assert(Def &&
"The record is expected to have a completed definition");
17807 unsigned NumInitMethods = 0;
17808 for (
auto *Method : Def->methods()) {
17809 if (!Method->getIdentifier())
17811 if (Method->getName() ==
"__init")
17814 if (NumInitMethods > 1 || !Def->hasInitMethod())
17815 Diag(RD->
getLocation(), diag::err_sycl_special_type_num_init_method);
17824 Tag->setTopLevelDeclInObjCContainer();
17827 if (!Tag->isInvalidDecl())
17838 const RecordDecl *RD = dyn_cast<RecordDecl>(Tag);
17842 if (llvm::any_of(RD->
fields(),
17843 [](
const FieldDecl *FD) { return FD->isBitField(); }))
17844 Diag(BraceRange.
getBegin(), diag::warn_pragma_align_not_xl_compatible);
17854 assert(ObjCCtx ==
CurContext &&
"Mismatch of container contexts");
17867 Tag->setInvalidDecl();
17870 if (Tag->isBeingDefined()) {
17871 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
17885 bool IsMsStruct,
Expr *BitWidth) {
17895 diag::err_field_incomplete_or_sizeless))
17898 return Diag(FieldLoc, diag::err_not_integral_type_bitfield)
17900 return Diag(FieldLoc, diag::err_not_integral_type_anon_bitfield)
17911 llvm::APSInt
Value;
17915 BitWidth = ICE.
get();
17918 if (
Value == 0 && FieldName)
17919 return Diag(FieldLoc, diag::err_bitfield_has_zero_width) << FieldName;
17921 if (
Value.isSigned() &&
Value.isNegative()) {
17923 return Diag(FieldLoc, diag::err_bitfield_has_negative_width)
17925 return Diag(FieldLoc, diag::err_anon_bitfield_has_negative_width)
17932 return Diag(FieldLoc, diag::err_bitfield_too_wide)
17939 bool BitfieldIsOverwide =
Value.ugt(TypeWidth);
17943 bool CStdConstraintViolation =
17945 bool MSBitfieldViolation =
17946 Value.ugt(TypeStorageSize) &&
17948 if (CStdConstraintViolation || MSBitfieldViolation) {
17949 unsigned DiagWidth =
17950 CStdConstraintViolation ? TypeWidth : TypeStorageSize;
17951 return Diag(FieldLoc, diag::err_bitfield_width_exceeds_type_width)
17953 << !CStdConstraintViolation << DiagWidth;
17959 if (BitfieldIsOverwide && !FieldTy->
isBooleanType() && FieldName) {
17960 Diag(FieldLoc, diag::warn_bitfield_width_exceeds_type_width)
17974 DeclStart, D,
static_cast<Expr*
>(BitfieldWidth),
18017 diag::err_invalid_thread)
18025 switch (
Previous.getResultKind()) {
18032 PrevDecl =
Previous.getRepresentativeDecl();
18046 PrevDecl =
nullptr;
18050 PrevDecl =
nullptr;
18056 =
CheckFieldDecl(II, T, TInfo, Record, Loc, Mutable, BitWidth, InitStyle,
18057 TSSL, AS, PrevDecl, &D);
18060 Record->setInvalidDecl();
18071 Record->addDecl(NewFD);
18089 bool Mutable,
Expr *BitWidth,
18095 bool InvalidDecl =
false;
18100 if (T.isNull() || T->containsErrors()) {
18101 InvalidDecl =
true;
18108 diag::err_field_incomplete_or_sizeless)) {
18110 Record->setInvalidDecl();
18111 InvalidDecl =
true;
18116 Record->setInvalidDecl();
18117 InvalidDecl =
true;
18123 if (T.hasAddressSpace() || T->isDependentAddressSpaceType() ||
18124 T->getBaseElementTypeUnsafe()->isDependentAddressSpaceType()) {
18125 Diag(Loc, diag::err_field_with_address_space);
18126 Record->setInvalidDecl();
18127 InvalidDecl =
true;
18133 if (T->isEventT() || T->isImageType() || T->isSamplerT() ||
18134 T->isBlockPointerType()) {
18135 Diag(Loc, diag::err_opencl_type_struct_or_union_field) << T;
18136 Record->setInvalidDecl();
18137 InvalidDecl =
true;
18142 "__cl_clang_bitfields",
LangOpts)) {
18143 Diag(Loc, diag::err_opencl_bitfields);
18144 InvalidDecl =
true;
18150 T.hasQualifiers()) {
18151 InvalidDecl =
true;
18152 Diag(Loc, diag::err_anon_bitfield_qualifiers);
18157 if (!InvalidDecl && T->isVariablyModifiedType()) {
18159 TInfo, T, Loc, diag::err_typecheck_field_variable_size))
18160 InvalidDecl =
true;
18165 diag::err_abstract_type_in_decl,
18167 InvalidDecl =
true;
18170 BitWidth =
nullptr;
18176 InvalidDecl =
true;
18177 BitWidth =
nullptr;
18182 if (!InvalidDecl && Mutable) {
18183 unsigned DiagID = 0;
18184 if (T->isReferenceType())
18185 DiagID =
getLangOpts().MSVCCompat ? diag::ext_mutable_reference
18186 : diag::err_mutable_reference;
18187 else if (T.isConstQualified())
18188 DiagID = diag::err_mutable_const;
18194 Diag(ErrLoc, DiagID);
18195 if (DiagID != diag::ext_mutable_reference) {
18197 InvalidDecl =
true;
18209 BitWidth, Mutable, InitStyle);
18213 if (PrevDecl && !isa<TagDecl>(PrevDecl)) {
18214 Diag(Loc, diag::err_duplicate_member) << II;
18220 if (Record->isUnion()) {
18221 if (
const RecordType *RT = EltTy->
getAs<RecordType>()) {
18239 diag::ext_union_member_of_reference_type :
18240 diag::err_union_member_of_reference_type)
18263 if (T.isObjCGCWeak())
18264 Diag(Loc, diag::warn_attribute_weak_on_field);
18283 if (
const RecordType *RT = EltTy->
getAs<RecordType>()) {
18315 if (!FD->
hasAttr<UnavailableAttr>())
18317 UnavailableAttr::IR_ARCFieldWithOwnership, Loc));
18323 diag::warn_cxx98_compat_nontrivial_union_or_anon_struct_member :
18324 diag::err_illegal_union_or_anon_struct_member)
18339 switch (ivarVisibility) {
18340 default: llvm_unreachable(
"Unknown visitibility kind");
18356 Expr *BitWidth = (
Expr*)BitfieldWidth;
18377 if (T->isReferenceType()) {
18378 Diag(Loc, diag::err_ivar_reference_type);
18383 else if (T->isVariablyModifiedType()) {
18385 TInfo, T, Loc, diag::err_typecheck_ivar_variable_size))
18399 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
18402 EnclosingContext = IMPDecl->getClassInterface();
18403 assert(EnclosingContext &&
"Implementation has no class interface!");
18406 EnclosingContext = EnclosingDecl;
18409 dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) {
18411 Diag(Loc, diag::err_misplaced_ivar) << CDecl->IsClassExtension();
18415 EnclosingContext = EnclosingDecl;
18420 DeclStart, Loc, II, T,
18421 TInfo, ac, (
Expr *)BitfieldWidth);
18426 if (PrevDecl &&
isDeclInScope(PrevDecl, EnclosingContext, S)
18427 && !isa<TagDecl>(PrevDecl)) {
18428 Diag(Loc, diag::err_duplicate_member) << II;
18455 !NewID->
isInvalidDecl() && isa<ObjCInterfaceDecl>(EnclosingDecl))
18456 Diag(Loc, diag::warn_ivars_in_interface);
18470 Decl *ivarDecl = AllIvarDecls[AllIvarDecls.size()-1];
18478 if (!CD->IsClassExtension())
18490 DeclLoc, DeclLoc,
nullptr,
18496 AllIvarDecls.push_back(Ivar);
18508 if (!Record->hasUserDeclaredDestructor()) {
18515 for (
auto *
Decl : Record->decls()) {
18516 if (
auto *DD = dyn_cast<CXXDestructorDecl>(
Decl)) {
18517 if (DD->isInvalidDecl())
18521 assert(DD->isIneligibleOrNotSelected() &&
"Selecting a destructor but a destructor was already selected.");
18535 Record->addedSelectedDestructor(dyn_cast<CXXDestructorDecl>(Best->Function));
18539 Msg = diag::err_ambiguous_destructor;
18544 Msg = diag::err_no_viable_destructor;
18555 Record->setInvalidDecl();
18562 Record->addedSelectedDestructor(dyn_cast<CXXDestructorDecl>(OCS.
begin()->Function));
18603 const Expr *Constraints = Method->getTrailingRequiresClause();
18605 SatisfactionStatus.push_back(
true);
18609 SatisfactionStatus.push_back(
false);
18611 SatisfactionStatus.push_back(Satisfaction.
IsSatisfied);
18615 for (
size_t i = 0; i < Methods.size(); i++) {
18616 if (!SatisfactionStatus[i])
18624 bool AnotherMethodIsMoreConstrained =
false;
18625 for (
size_t j = 0; j < Methods.size(); j++) {
18626 if (i == j || !SatisfactionStatus[j])
18637 if (!OtherConstraints)
18639 if (!Constraints) {
18640 AnotherMethodIsMoreConstrained =
true;
18645 AnotherMethodIsMoreConstrained)) {
18648 AnotherMethodIsMoreConstrained =
true;
18650 if (AnotherMethodIsMoreConstrained)
18655 if (!AnotherMethodIsMoreConstrained) {
18656 Method->setIneligibleOrNotSelected(
false);
18657 Record->addedEligibleSpecialMemberFunction(Method, 1 << CSM);
18670 for (
auto *
Decl : Record->decls()) {
18671 auto *MD = dyn_cast<CXXMethodDecl>(
Decl);
18673 auto *FTD = dyn_cast<FunctionTemplateDecl>(
Decl);
18675 MD = dyn_cast<CXXMethodDecl>(FTD->getTemplatedDecl());
18679 if (
auto *CD = dyn_cast<CXXConstructorDecl>(MD)) {
18680 if (CD->isInvalidDecl())
18682 if (CD->isDefaultConstructor())
18683 DefaultConstructors.push_back(MD);
18684 else if (CD->isCopyConstructor())
18685 CopyConstructors.push_back(MD);
18686 else if (CD->isMoveConstructor())
18687 MoveConstructors.push_back(MD);
18689 CopyAssignmentOperators.push_back(MD);
18691 MoveAssignmentOperators.push_back(MD);
18709 assert(EnclosingDecl &&
"missing record or interface decl");
18714 if (!Fields.empty() && isa<ObjCContainerDecl>(EnclosingDecl)) {
18718 case Decl::ObjCCategory:
18721 case Decl::ObjCImplementation:
18723 ResetObjCLayout(cast<ObjCImplementationDecl>(DC)->getClassInterface());
18728 RecordDecl *Record = dyn_cast<RecordDecl>(EnclosingDecl);
18729 CXXRecordDecl *CXXRecord = dyn_cast<CXXRecordDecl>(EnclosingDecl);
18733 unsigned NumNamedMembers = 0;
18735 for (
const auto *I : Record->decls()) {
18736 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(I))
18737 if (IFD->getDeclName())
18754 RecFields.push_back(FD);
18774 bool IsLastField = (i + 1 == Fields.end());
18783 (Record || isa<ObjCContainerDecl>(EnclosingDecl))) {
18789 unsigned DiagID = 0;
18790 if (!Record->isUnion() && !IsLastField) {
18793 Diag((*(i + 1))->getLocation(), diag::note_next_field_declaration);
18797 }
else if (Record->isUnion())
18799 ? diag::ext_flexible_array_union_ms
18801 ? diag::ext_flexible_array_union_gnu
18802 : diag::err_flexible_array_union;
18803 else if (NumNamedMembers < 1)
18805 ? diag::ext_flexible_array_empty_aggregate_ms
18807 ? diag::ext_flexible_array_empty_aggregate_gnu
18808 : diag::err_flexible_array_empty_aggregate;
18812 << Record->getTagKind();
18818 if (CXXRecord && CXXRecord->getNumVBases() != 0)
18832 Diag(FD->
getLocation(), diag::err_flexible_array_has_nontrivial_dtor)
18839 Record->setHasFlexibleArrayMember(
true);
18848 diag::err_field_incomplete_or_sizeless)) {
18853 }
else if (
const RecordType *FDTTy = FDTy->
getAs<RecordType>()) {
18854 if (Record && FDTTy->getDecl()->hasFlexibleArrayMember()) {
18857 Record->setHasFlexibleArrayMember(
true);
18858 if (!Record->isUnion()) {
18873 if (isa<ObjCContainerDecl>(EnclosingDecl) &&
18875 diag::err_abstract_type_in_decl,
18880 if (Record && FDTTy->getDecl()->hasObjectMember())
18881 Record->setHasObjectMember(
true);
18882 if (Record && FDTTy->getDecl()->hasVolatileMember())
18883 Record->setHasVolatileMember(
true);
18890 }
else if (Record && Record->isUnion() &&
18902 FD->
addAttr(UnavailableAttr::CreateImplicit(
18903 Context,
"", UnavailableAttr::IR_ARCFieldWithOwnership,
18907 !Record->hasObjectMember()) {
18910 Record->setHasObjectMember(
true);
18913 if (BaseType->isRecordType() &&
18914 BaseType->castAs<RecordType>()->getDecl()->hasObjectMember())
18915 Record->setHasObjectMember(
true);
18916 else if (BaseType->isObjCObjectPointerType() ||
18917 BaseType.isObjCGCStrong())
18918 Record->setHasObjectMember(
true);
18923 !shouldIgnoreForRecordTriviality(FD)) {
18926 Record->setNonTrivialToPrimitiveDefaultInitialize(
true);
18929 Record->setHasNonTrivialToPrimitiveDefaultInitializeCUnion(
true);
18933 Record->setNonTrivialToPrimitiveCopy(
true);
18935 Record->setHasNonTrivialToPrimitiveCopyCUnion(
true);
18938 Record->setNonTrivialToPrimitiveDestroy(
true);
18939 Record->setParamDestroyedInCallee(
true);
18941 Record->setHasNonTrivialToPrimitiveDestructCUnion(
true);
18944 if (
const auto *RT = FT->
getAs<RecordType>()) {
18945 if (RT->getDecl()->getArgPassingRestrictions() ==
18953 Record->setHasVolatileMember(
true);
18961 bool Completed =
false;
18963 if (!CXXRecord->isInvalidDecl()) {
18966 I = CXXRecord->conversion_begin(),
18967 E = CXXRecord->conversion_end(); I != E; ++I)
18968 I.setAccess((*I)->getAccess());
18974 if (!CXXRecord->isDependentType()) {
18975 if (!CXXRecord->isInvalidDecl()) {
18979 if (CXXRecord->getNumVBases()) {
18981 CXXRecord->getFinalOverriders(FinalOverriders);
18983 for (CXXFinalOverriderMap::iterator M = FinalOverriders.begin(),
18984 MEnd = FinalOverriders.end();
18987 SOEnd = M->second.end();
18988 SO != SOEnd; ++SO) {
18989 assert(SO->second.size() > 0 &&
18990 "Virtual function without overriding functions?");
18991 if (SO->second.size() == 1)
18998 Diag(Record->getLocation(), diag::err_multiple_final_overriders)
18999 << (
const NamedDecl *)M->first << Record;
19000 Diag(M->first->getLocation(),
19001 diag::note_overridden_virtual_function);
19003 OM = SO->second.begin(),
19004 OMEnd = SO->second.end();
19006 Diag(OM->Method->getLocation(), diag::note_final_overrider)
19007 << (
const NamedDecl *)M->first << OM->Method->getParent();
19009 Record->setInvalidDecl();
19012 CXXRecord->completeDefinition(&FinalOverriders);
19022 Record->completeDefinition();
19028 auto IsFunctionPointerOrForwardDecl = [&](
const Decl *D) {
19029 const FieldDecl *FD = dyn_cast<FieldDecl>(D);
19042 if (
const auto *TD = dyn_cast<TagDecl>(D))
19043 return !TD->isCompleteDefinition();
19047 if (isa<PointerType>(FieldType)) {
19057 (Record->hasAttr<RandomizeLayoutAttr>() ||
19058 (!Record->hasAttr<NoRandomizeLayoutAttr>() &&
19059 llvm::all_of(Record->decls(), IsFunctionPointerOrForwardDecl))) &&
19060 !Record->isUnion() && !
getLangOpts().RandstructSeed.empty() &&
19061 !Record->isRandomized()) {
19065 Record->reorderDecls(NewDeclOrdering);
19070 auto *Dtor = CXXRecord->getDestructor();
19071 if (Dtor && Dtor->isImplicit() &&
19073 CXXRecord->setImplicitDestructorIsDeleted();
19078 if (Record->hasAttrs()) {
19081 if (
const MSInheritanceAttr *IA = Record->getAttr<MSInheritanceAttr>())
19083 IA->getRange(), IA->getBestCase(),
19084 IA->getInheritanceModel());
19090 bool CheckForZeroSize;
19092 CheckForZeroSize =
true;
19097 CXXRecord->getLexicalDeclContext()->isExternCContext() &&
19099 CXXRecord->isCLike();
19101 if (CheckForZeroSize) {
19102 bool ZeroSize =
true;
19103 bool IsEmpty =
true;
19104 unsigned NonBitFields = 0;
19106 E = Record->field_end();
19107 (NonBitFields == 0 || ZeroSize) && I != E; ++I) {
19109 if (I->isUnnamedBitfield()) {
19110 if (!I->isZeroLengthBitField(
Context))
19114 QualType FieldType = I->getType();
19126 diag::warn_zero_size_struct_union_in_extern_c :
19127 diag::warn_zero_size_struct_union_compat)
19128 << IsEmpty << Record->isUnion() << (NonBitFields > 1);
19134 Diag(RecLoc, IsEmpty ? diag::ext_empty_struct_union :
19135 diag::ext_no_named_members_in_struct_union)
19136 << Record->isUnion();
19143 ID->setEndOfDefinitionLoc(RBrac);
19145 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
19147 ID->addDecl(ClsFields[i]);
19151 if (ID->getSuperClass())
19154 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
19155 assert(IMPDecl &&
"ActOnFields - missing ObjCImplementationDecl");
19156 for (
unsigned I = 0,
N = RecFields.size(); I !=
N; ++I)
19161 IMPDecl->setIvarLBraceLoc(LBrac);
19162 IMPDecl->setIvarRBraceLoc(RBrac);
19164 dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) {
19172 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
19176 Diag(ClsFields[i]->getLocation(),
19177 diag::err_duplicate_ivar_declaration);
19178 Diag(ClsIvar->getLocation(), diag::note_previous_definition);
19184 Diag(ClsFields[i]->getLocation(),
19185 diag::err_duplicate_ivar_declaration);
19186 Diag(ClsExtIvar->getLocation(), diag::note_previous_definition);
19192 CDecl->addDecl(ClsFields[i]);
19194 CDecl->setIvarLBraceLoc(LBrac);
19195 CDecl->setIvarRBraceLoc(RBrac);
19203 llvm::APSInt &
Value,
19205 assert((T->isIntegralType(Context) || T->isEnumeralType()) &&
19206 "Integral type required!");
19209 if (
Value.isUnsigned() ||
Value.isNonNegative()) {
19210 if (T->isSignedIntegerOrEnumerationType())
19212 return Value.getActiveBits() <= BitWidth;
19214 return Value.getSignificantBits() <= BitWidth;
19222 assert((T->isIntegralType(Context) ||
19223 T->isEnumeralType()) &&
"Integral type required!");
19224 const unsigned NumTypes = 4;
19225 QualType SignedIntegralTypes[NumTypes] = {
19228 QualType UnsignedIntegralTypes[NumTypes] = {
19234 QualType *Types = T->isSignedIntegerOrEnumerationType()? SignedIntegralTypes
19235 : UnsignedIntegralTypes;
19236 for (
unsigned I = 0; I != NumTypes; ++I)
19249 llvm::APSInt EnumVal(IntWidth);
19269 EltTy =
Enum->getIntegerType();
19276 Val = Converted.
get();
19283 if (
Enum->isComplete()) {
19284 EltTy =
Enum->getIntegerType();
19293 .isWindowsMSVCEnvironment()) {
19294 Diag(IdLoc, diag::ext_enumerator_too_large) << EltTy;
19296 Diag(IdLoc, diag::err_enumerator_too_large) << EltTy;
19320 Diag(IdLoc, diag::ext_enum_value_not_int)
19322 << (EnumVal.isUnsigned() || EnumVal.isNonNegative());
19334 if (
Enum->isDependentType())
19336 else if (!LastEnumConst) {
19345 if (
Enum->isFixed()) {
19346 EltTy =
Enum->getIntegerType();
19355 EltTy = LastEnumConst->
getType();
19358 if (EnumVal < LastEnumConst->getInitVal()) {
19370 if (T.isNull() ||
Enum->isFixed()) {
19374 EnumVal = EnumVal.zext(EnumVal.getBitWidth() * 2);
19376 if (
Enum->isFixed())
19378 Diag(IdLoc, diag::err_enumerator_wrapped)
19382 Diag(IdLoc, diag::ext_enumerator_increment_too_large)
19402 Diag(IdLoc, diag::warn_enum_value_overflow);
19407 Diag(IdLoc, diag::ext_enum_value_not_int)
19435 auto *PrevECD = dyn_cast_or_null<EnumConstantDecl>(PrevDecl);
19456 cast_or_null<EnumConstantDecl>(lastEnumConst);
19472 PrevDecl =
nullptr;
19490 if (!TheEnumDecl->
isScoped() && isa<ValueDecl>(PrevDecl)) {
19498 "Received TagDecl when not in C++!");
19500 if (isa<EnumConstantDecl>(PrevDecl))
19501 Diag(IdLoc, diag::err_redefinition_of_enumerator) <<
Id;
19503 Diag(IdLoc, diag::err_redefinition) <<
Id;
19535 if (!BO->isAdditiveOp())
19543 InitExpr = BO->getLHS();
19547 DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(InitExpr);
19567 if (!
Enum->getIdentifier())
19571 if (
Enum->getNumPositiveBits() > 63 ||
Enum->getNumNegativeBits() > 64)
19580 typedef llvm::PointerUnion<EnumConstantDecl*, ECDVector*> DeclOrVector;
19583 typedef std::unordered_map<int64_t, DeclOrVector> ValueToVectorMap;
19587 llvm::APSInt Val = D->getInitVal();
19588 return Val.isSigned() ? Val.getSExtValue() : Val.getZExtValue();
19591 DuplicatesVector DupVector;
19592 ValueToVectorMap EnumMap;
19596 for (
auto *Element : Elements) {
19610 EnumMap.insert({EnumConstantToKey(ECD), ECD});
19613 if (EnumMap.size() == 0)
19617 for (
auto *Element : Elements) {
19623 auto Iter = EnumMap.find(EnumConstantToKey(ECD));
19624 if (Iter == EnumMap.end())
19627 DeclOrVector& Entry = Iter->second;
19634 auto Vec = std::make_unique<ECDVector>();
19636 Vec->push_back(ECD);
19643 DupVector.emplace_back(std::move(Vec));
19647 ECDVector *Vec = Entry.get<ECDVector*>();
19649 if (*Vec->begin() == ECD)
19652 Vec->push_back(ECD);
19656 for (
const auto &Vec : DupVector) {
19657 assert(Vec->size() > 1 &&
"ECDVector should have at least 2 elements.");
19660 auto *FirstECD = Vec->front();
19661 S.
Diag(FirstECD->getLocation(), diag::warn_duplicate_enum_values)
19662 << FirstECD <<
toString(FirstECD->getInitVal(), 10)
19663 << FirstECD->getSourceRange();
19667 for (
auto *ECD : llvm::drop_begin(*Vec))
19668 S.
Diag(ECD->getLocation(), diag::note_duplicate_element)
19669 << ECD <<
toString(ECD->getInitVal(), 10)
19670 << ECD->getSourceRange();
19675 bool AllowMask)
const {
19676 assert(ED->
isClosedFlag() &&
"looking for value in non-flag or open enum");
19679 auto R =
FlagBitsCache.insert(std::make_pair(ED, llvm::APInt()));
19680 llvm::APInt &FlagBits = R.first->second;
19684 const auto &EVal = E->getInitVal();
19686 if (EVal.isPowerOf2())
19687 FlagBits = FlagBits.zext(EVal.getBitWidth()) | EVal;
19699 llvm::APInt FlagMask = ~FlagBits.zextOrTrunc(Val.getBitWidth());
19700 return !(FlagMask & Val) || (AllowMask && !(FlagMask & ~Val));
19711 if (
Enum->isDependentType()) {
19712 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
19714 cast_or_null<EnumConstantDecl>(Elements[i]);
19715 if (!ECD)
continue;
19733 unsigned NumNegativeBits = 0;
19734 unsigned NumPositiveBits = 0;
19736 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
19738 cast_or_null<EnumConstantDecl>(Elements[i]);
19739 if (!ECD)
continue;
19741 const llvm::APSInt &InitVal = ECD->
getInitVal();
19744 if (InitVal.isUnsigned() || InitVal.isNonNegative()) {
19747 unsigned ActiveBits = InitVal.getActiveBits();
19748 NumPositiveBits = std::max({NumPositiveBits, ActiveBits, 1u});
19751 std::max(NumNegativeBits, (
unsigned)InitVal.getSignificantBits());
19759 if (!NumPositiveBits && !NumNegativeBits)
19760 NumPositiveBits = 1;
19764 unsigned BestWidth;
19785 if (
Enum->isComplete()) {
19786 BestType =
Enum->getIntegerType();
19790 BestPromotionType = BestType;
19794 else if (NumNegativeBits) {
19798 if (Packed && NumNegativeBits <= CharWidth && NumPositiveBits < CharWidth) {
19800 BestWidth = CharWidth;
19801 }
else if (Packed && NumNegativeBits <= ShortWidth &&
19802 NumPositiveBits < ShortWidth) {
19804 BestWidth = ShortWidth;
19805 }
else if (NumNegativeBits <= IntWidth && NumPositiveBits < IntWidth) {
19807 BestWidth = IntWidth;
19811 if (NumNegativeBits <= BestWidth && NumPositiveBits < BestWidth) {
19816 if (NumNegativeBits > BestWidth || NumPositiveBits >= BestWidth)
19817 Diag(
Enum->getLocation(), diag::ext_enum_too_large);
19821 BestPromotionType = (BestWidth <= IntWidth ?
Context.
IntTy : BestType);
19826 if (Packed && NumPositiveBits <= CharWidth) {
19829 BestWidth = CharWidth;
19830 }
else if (Packed && NumPositiveBits <= ShortWidth) {
19833 BestWidth = ShortWidth;
19834 }
else if (NumPositiveBits <= IntWidth) {
19836 BestWidth = IntWidth;
19838 = (NumPositiveBits == BestWidth || !
getLangOpts().CPlusPlus)
19840 }
else if (NumPositiveBits <=
19844 = (NumPositiveBits == BestWidth || !
getLangOpts().CPlusPlus)
19848 assert(NumPositiveBits <= BestWidth &&
19849 "How could an initializer get larger than ULL?");
19852 = (NumPositiveBits == BestWidth || !
getLangOpts().CPlusPlus)
19859 for (
auto *D : Elements) {
19860 auto *ECD = cast_or_null<EnumConstantDecl>(D);
19861 if (!ECD)
continue;
19870 llvm::APSInt InitVal = ECD->getInitVal();
19878 !
Enum->isFixed() &&
19881 NewWidth = IntWidth;
19883 }
else if (ECD->getType() == BestType) {
19889 ECD->setType(EnumType);
19893 NewWidth = BestWidth;
19898 InitVal = InitVal.extOrTrunc(NewWidth);
19899 InitVal.setIsSigned(NewSign);
19900 ECD->setInitVal(InitVal);
19903 if (ECD->getInitExpr() &&
19906 Context, NewTy, CK_IntegralCast, ECD->getInitExpr(),
19912 ECD->setType(EnumType);
19914 ECD->setType(NewTy);
19917 Enum->completeDefinition(BestType, BestPromotionType,
19918 NumPositiveBits, NumNegativeBits);
19922 if (
Enum->isClosedFlag()) {
19923 for (
Decl *D : Elements) {
19925 if (!ECD)
continue;
19928 if (InitVal != 0 && !InitVal.isPowerOf2() &&
19936 if (
Enum->hasAttrs())
19946 AsmString, StartLoc,
19967 AsmLabelAttr *
Attr = AsmLabelAttr::CreateImplicit(
19974 if (PrevDecl && (isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl))) {
19978 Diag(PrevDecl->
getLocation(), diag::warn_redefine_extname_not_applied)
19991 PrevDecl->
addAttr(WeakAttr::CreateImplicit(
Context, PragmaLoc));
20006 if (PrevDecl && (isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl))) {
20007 if (!PrevDecl->
hasAttr<AliasAttr>())
20008 if (
NamedDecl *ND = dyn_cast<NamedDecl>(PrevDecl))
20016 return (dyn_cast_or_null<ObjCContainerDecl>(
CurContext));
20021 assert(FD &&
"Expected non-null FunctionDecl");
20033 auto IsEmittedForExternalSymbol = [
this, FD]() {
20043 if (
LangOpts.OpenMPIsTargetDevice) {
20046 std::optional<OMPDeclareTargetDeclAttr::DevTypeTy> DevTy =
20053 if (*DevTy == OMPDeclareTargetDeclAttr::DT_Host)
20058 if (IsEmittedForExternalSymbol())
20064 }
else if (
LangOpts.OpenMP > 45) {
20068 std::optional<OMPDeclareTargetDeclAttr::DevTypeTy> DevTy =
20071 if (*DevTy == OMPDeclareTargetDeclAttr::DT_NoHost)
20090 if (IsEmittedForExternalSymbol())
Defines the clang::ASTContext interface.
This file provides some common utility functions for processing Lambda related AST Constructs.
static constexpr Builtin::Info BuiltinInfo[]
Defines enum values for all the target-independent builtin functions.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines the classes used to store parsed information about declaration-specifiers and decla...
Defines the C++ template declaration subclasses.
static bool isDeclExternC(const T &D)
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
static bool hasDefinition(const ObjCObjectPointerType *ObjPtr)
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines helper utilities for supporting the HLSL runtime environment.
static const Decl * getCanonicalDecl(const Decl *D)
static const GlobalDecl isTemplate(GlobalDecl GD, const TemplateArgumentList *&TemplateArgs)
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
static bool isExternC(const NamedDecl *ND)
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
Defines the clang::Preprocessor interface.
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
static bool hasAttr(const FunctionDecl *D, bool IgnoreImplicitAttr)
static bool isFunctionOrMethod(const Decl *D)
isFunctionOrMethod - Return true if the given decl has function type (function or function-typed vari...
static void diagnoseImplicitlyRetainedSelf(Sema &S)
static void SetNestedNameSpecifier(Sema &S, DeclaratorDecl *DD, Declarator &D)
static UnqualifiedTypeNameLookupResult lookupUnqualifiedTypeNameInBase(Sema &S, const IdentifierInfo &II, SourceLocation NameLoc, const CXXRecordDecl *RD)
Tries to perform unqualified lookup of the type decls in bases for dependent class.
static bool ShouldWarnAboutMissingPrototype(const FunctionDecl *FD, const FunctionDecl *&PossiblePrototype)
static bool PreviousDeclsHaveMultiVersionAttribute(const FunctionDecl *FD)
static ParsedType recoverFromTypeInKnownDependentBase(Sema &S, const IdentifierInfo &II, SourceLocation NameLoc)
static void mergeParamDeclTypes(ParmVarDecl *NewParam, const ParmVarDecl *OldParam, Sema &S)
static void adjustDeclContextForDeclaratorDecl(DeclaratorDecl *NewD, DeclaratorDecl *OldD)
If necessary, adjust the semantic declaration context for a qualified declaration to name the correct...
static bool isResultTypeOrTemplate(LookupResult &R, const Token &NextToken)
Determine whether the given result set contains either a type name or.
static void FixInvalidVariablyModifiedTypeLoc(TypeLoc SrcTL, TypeLoc DstTL)
static bool AllowOverloadingOfFunction(const LookupResult &Previous, ASTContext &Context, const FunctionDecl *New)
Determine whether overloading is allowed for a new function declaration considering prior declaration...
static TypeSourceInfo * TryToFixInvalidVariablyModifiedTypeSourceInfo(TypeSourceInfo *TInfo, ASTContext &Context, bool &SizeIsNegative, llvm::APSInt &Oversized)
Helper method to turn variable array types into constant array types in certain situations which woul...
static StringRef getHeaderName(Builtin::Context &BuiltinInfo, unsigned ID, ASTContext::GetBuiltinTypeError Error)
static StorageClass getFunctionStorageClass(Sema &SemaRef, Declarator &D)
static bool checkUsingShadowRedecl(Sema &S, UsingShadowDecl *OldS, ExpectedDecl *New)
Check whether a redeclaration of an entity introduced by a using-declaration is valid,...
static bool mergeDeclAttribute(Sema &S, NamedDecl *D, const InheritableAttr *Attr, Sema::AvailabilityMergeKind AMK)
static void SetEligibleMethods(Sema &S, CXXRecordDecl *Record, ArrayRef< CXXMethodDecl * > Methods, Sema::CXXSpecialMember CSM)
[class.mem.special]p6: An eligible special member function is a special member function for which:
static ShadowedDeclKind computeShadowedDeclKind(const NamedDecl *ShadowedDecl, const DeclContext *OldDC)
Determine what kind of declaration we're shadowing.
static void checkIsValidOpenCLKernelParameter(Sema &S, Declarator &D, ParmVarDecl *Param, llvm::SmallPtrSetImpl< const Type * > &ValidTypes)
static void mergeParamDeclAttributes(ParmVarDecl *newDecl, const ParmVarDecl *oldDecl, Sema &S)
mergeParamDeclAttributes - Copy attributes from the old parameter to the new one.
void emitReadOnlyPlacementAttrWarning(Sema &S, const VarDecl *VD)
static bool CheckMultiVersionFunction(Sema &S, FunctionDecl *NewFD, bool &Redeclaration, NamedDecl *&OldDecl, LookupResult &Previous)
Check the validity of a mulitversion function declaration.
static bool mergeAlignedAttrs(Sema &S, NamedDecl *New, Decl *Old)
Merge alignment attributes from Old to New, taking into account the special semantics of C11's _Align...
static bool mergeTypeWithPrevious(Sema &S, VarDecl *NewVD, VarDecl *OldVD, LookupResult &Previous)
static bool FindPossiblePrototype(const FunctionDecl *FD, const FunctionDecl *&PossiblePrototype)
static void GenerateFixForUnusedDecl(const NamedDecl *D, ASTContext &Ctx, FixItHint &Hint)
static NestedNameSpecifier * synthesizeCurrentNestedNameSpecifier(ASTContext &Context, DeclContext *DC)
static bool isFunctionDefinitionDiscarded(Sema &S, FunctionDecl *FD)
Given that we are within the definition of the given function, will that definition behave like C99's...
static bool isRepresentableIntegerValue(ASTContext &Context, llvm::APSInt &Value, QualType T)
Determine whether the given integral value is representable within the given type T.
static void CheckForDuplicateEnumValues(Sema &S, ArrayRef< Decl * > Elements, EnumDecl *Enum, QualType EnumType)
static unsigned GetDiagnosticTypeSpecifierID(const DeclSpec &DS)
static void checkNewAttributesAfterDef(Sema &S, Decl *New, const Decl *Old)
checkNewAttributesAfterDef - If we already have a definition, check that there are no new attributes ...
static bool isClassCompatTagKind(TagTypeKind Tag)
Determine if tag kind is a class-key compatible with class for redeclaration (class,...
static bool hasIdenticalPassObjectSizeAttrs(const FunctionDecl *A, const FunctionDecl *B)
static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND)
static bool hasSimilarParameters(ASTContext &Context, FunctionDecl *Declaration, FunctionDecl *Definition, SmallVectorImpl< unsigned > &Params)
hasSimilarParameters - Determine whether the C++ functions Declaration and Definition have "nearly" m...
static NonCLikeKind getNonCLikeKindForAnonymousStruct(const CXXRecordDecl *RD)
Determine whether a class is C-like, according to the rules of C++ [dcl.typedef] for anonymous classe...
static FunctionDecl * CreateNewFunctionDecl(Sema &SemaRef, Declarator &D, DeclContext *DC, QualType &R, TypeSourceInfo *TInfo, StorageClass SC, bool &IsVirtualOkay)
static Scope * getTagInjectionScope(Scope *S, const LangOptions &LangOpts)
Find the Scope in which a tag is implicitly declared if we see an elaborated type specifier in the sp...
static std::pair< diag::kind, SourceLocation > getNoteDiagForInvalidRedeclaration(const T *Old, const T *New)
static bool checkForConflictWithNonVisibleExternC(Sema &S, const T *ND, LookupResult &Previous)
Apply special rules for handling extern "C" declarations.
static bool DeclHasAttr(const Decl *D, const Attr *A)
DeclhasAttr - returns true if decl Declaration already has the target attribute.
static bool isOpenCLSizeDependentType(ASTContext &C, QualType Ty)
static void diagnoseMissingConstinit(Sema &S, const VarDecl *InitDecl, const ConstInitAttr *CIAttr, bool AttrBeforeInit)
static bool shouldWarnIfShadowedDecl(const DiagnosticsEngine &Diags, const LookupResult &R)
static FixItHint createFriendTagNNSFixIt(Sema &SemaRef, NamedDecl *ND, Scope *S, SourceLocation NameLoc)
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
static bool AreSpecialMemberFunctionsSameKind(ASTContext &Context, CXXMethodDecl *M1, CXXMethodDecl *M2, Sema::CXXSpecialMember CSM)
[class.mem.special]p5 Two special member functions are of the same kind if:
static bool checkGlobalOrExternCConflict(Sema &S, const T *ND, bool IsGlobal, LookupResult &Previous)
Check for conflict between this global or extern "C" declaration and previous global or extern "C" de...
static bool isStdBuiltin(ASTContext &Ctx, FunctionDecl *FD, unsigned BuiltinID)
Determine whether a declaration matches a known function in namespace std.
@ InvalidAddrSpacePtrKernelParam
static bool isFromSystemHeader(SourceManager &SM, const Decl *D)
Returns true if the declaration is declared in a system header or from a system macro.
static const CXXRecordDecl * findRecordWithDependentBasesOfEnclosingMethod(const DeclContext *DC)
Find the parent class with dependent bases of the innermost enclosing method context.
static void ComputeSelectedDestructor(Sema &S, CXXRecordDecl *Record)
[class.dtor]p4: At the end of the definition of a class, overload resolution is performed among the p...
static bool shouldConsiderLinkage(const VarDecl *VD)
static SourceLocation findDefaultInitializer(const CXXRecordDecl *Record)
static bool CheckMultiVersionAdditionalRules(Sema &S, const FunctionDecl *OldFD, const FunctionDecl *NewFD, bool CausesMV, MultiVersionKind MVKind)
static DeclContext * getTagInjectionContext(DeclContext *DC)
Find the DeclContext in which a tag is implicitly declared if we see an elaborated type specifier in ...
static bool EquivalentArrayTypes(QualType Old, QualType New, const ASTContext &Ctx)
static bool haveIncompatibleLanguageLinkages(const T *Old, const T *New)
static unsigned getRedeclDiagFromTagKind(TagTypeKind Tag)
Get diagnostic select index for tag kind for redeclaration diagnostic message.
static bool MultiVersionTypesCompatible(MultiVersionKind Old, MultiVersionKind New)
static void CheckPoppedLabel(LabelDecl *L, Sema &S, Sema::DiagReceiverTy DiagReceiver)
static void diagnoseVarDeclTypeMismatch(Sema &S, VarDecl *New, VarDecl *Old)
static bool CheckAnonMemberRedeclaration(Sema &SemaRef, Scope *S, DeclContext *Owner, DeclarationName Name, SourceLocation NameLoc, bool IsUnion)
We are trying to inject an anonymous member into the given scope; check if there's an existing declar...
static NamedDecl * DiagnoseInvalidRedeclaration(Sema &SemaRef, LookupResult &Previous, FunctionDecl *NewFD, ActOnFDArgs &ExtraArgs, bool IsLocalFriend, Scope *S)
Generate diagnostics for an invalid function redeclaration.
static bool RebuildDeclaratorInCurrentInstantiation(Sema &S, Declarator &D, DeclarationName Name)
RebuildDeclaratorInCurrentInstantiation - Checks whether the given declarator needs to be rebuilt in ...
static bool isTagTypeWithMissingTag(Sema &SemaRef, LookupResult &Result, Scope *S, CXXScopeSpec &SS, IdentifierInfo *&Name, SourceLocation NameLoc)
static bool hasParsedAttr(Scope *S, const Declarator &PD, ParsedAttr::Kind Kind)
ShadowedDeclKind
Enum describing the select options in diag::warn_decl_shadow.
static unsigned getMSManglingNumber(const LangOptions &LO, Scope *S)
static bool InjectAnonymousStructOrUnionMembers(Sema &SemaRef, Scope *S, DeclContext *Owner, RecordDecl *AnonRecord, AccessSpecifier AS, SmallVectorImpl< NamedDecl * > &Chaining)
InjectAnonymousStructOrUnionMembers - Inject the members of the anonymous struct or union AnonRecord ...
static bool canRedefineFunction(const FunctionDecl *FD, const LangOptions &LangOpts)
canRedefineFunction - checks if a function can be redefined.
static ObjCIvarDecl::AccessControl TranslateIvarVisibility(tok::ObjCKeywordKind ivarVisibility)
TranslateIvarVisibility - Translate visibility from a token ID to an AST enum value.
static OpenCLParamType getOpenCLKernelParameterType(Sema &S, QualType PT)
static void checkDuplicateDefaultInit(Sema &S, CXXRecordDecl *Parent, SourceLocation DefaultInitLoc)
static bool isDefaultStdCall(FunctionDecl *FD, Sema &S)
static bool diagnoseOpenCLTypes(Sema &Se, VarDecl *NewVD)
Returns true if there hasn't been any invalid type diagnosed.
static void RemoveUsingDecls(LookupResult &R)
Removes using shadow declarations not at class scope from the lookup results.
static void ComputeSpecialMemberFunctionsEligiblity(Sema &S, CXXRecordDecl *Record)
static bool AttrCompatibleWithMultiVersion(attr::Kind Kind, MultiVersionKind MVKind)
static bool isUsingDeclNotAtClassScope(NamedDecl *D)
static void filterNonConflictingPreviousTypedefDecls(Sema &S, TypedefNameDecl *Decl, LookupResult &Previous)
Typedef declarations don't have linkage, but they still denote the same entity if their types are the...
static void RebuildLambdaScopeInfo(CXXMethodDecl *CallOperator, Sema &S)
static const NamedDecl * getDefinition(const Decl *D)
static QualType TryToFixInvalidVariablyModifiedType(QualType T, ASTContext &Context, bool &SizeIsNegative, llvm::APSInt &Oversized)
Helper method to turn variable array types into constant array types in certain situations which woul...
static bool hasDeducedAuto(DeclaratorDecl *DD)
static void copyAttrFromTypedefToDecl(Sema &S, Decl *D, const TypedefType *TT)
static QualType getCoreType(QualType Ty)
static bool CheckTargetCausesMultiVersioning(Sema &S, FunctionDecl *OldFD, FunctionDecl *NewFD, bool &Redeclaration, NamedDecl *&OldDecl, LookupResult &Previous)
static bool isMainFileLoc(const Sema &S, SourceLocation Loc)
static bool CheckMultiVersionValue(Sema &S, const FunctionDecl *FD)
Check the target or target_version attribute of the function for MultiVersion validity.
static bool isOutOfScopePreviousDeclaration(NamedDecl *, DeclContext *, ASTContext &)
Determines whether the given declaration is an out-of-scope previous declaration.
static StorageClass StorageClassSpecToVarDeclStorageClass(const DeclSpec &DS)
StorageClassSpecToVarDeclStorageClass - Maps a DeclSpec::SCS to a VarDecl::StorageClass.
static ParsedType buildNamedType(Sema &S, const CXXScopeSpec *SS, QualType T, SourceLocation NameLoc, bool WantNontrivialTypeSourceInfo=true)
Build a ParsedType for a simple-type-specifier with a nested-name-specifier.
static SourceLocation getCaptureLocation(const LambdaScopeInfo *LSI, const VarDecl *VD)
Return the location of the capture if the given lambda captures the given variable VD,...
static bool CheckMultiVersionFirstFunction(Sema &S, FunctionDecl *FD)
Check the validity of a multiversion function declaration that is the first of its kind.
static void checkDLLAttributeRedeclaration(Sema &S, NamedDecl *OldDecl, NamedDecl *NewDecl, bool IsSpecialization, bool IsDefinition)
static bool checkNonMultiVersionCompatAttributes(Sema &S, const FunctionDecl *FD, const FunctionDecl *CausedFD, MultiVersionKind MVKind)
static bool ShouldDiagnoseUnusedDecl(const NamedDecl *D)
static bool ValidDuplicateEnum(EnumConstantDecl *ECD, EnumDecl *Enum)
static QualType getNextLargerIntegralType(ASTContext &Context, QualType T)
static bool CheckMultiVersionAdditionalDecl(Sema &S, FunctionDecl *OldFD, FunctionDecl *NewFD, MultiVersionKind NewMVKind, const CPUDispatchAttr *NewCPUDisp, const CPUSpecificAttr *NewCPUSpec, const TargetClonesAttr *NewClones, bool &Redeclaration, NamedDecl *&OldDecl, LookupResult &Previous)
Check the validity of a new function declaration being added to an existing multiversioned declaratio...
static bool isIncompleteDeclExternC(Sema &S, const T *D)
Determine whether a variable is extern "C" prior to attaching an initializer.
static bool isAttributeTargetADefinition(Decl *D)
static Attr * getImplicitCodeSegAttrFromClass(Sema &S, const FunctionDecl *FD)
Return a CodeSegAttr from a containing class.
static bool IsDisallowedCopyOrAssign(const CXXMethodDecl *D)
Check for this common pattern:
static bool isAcceptableTagRedeclContext(Sema &S, DeclContext *OldDC, DeclContext *NewDC)
Determine whether a tag originally declared in context OldDC can be redeclared with an unqualified na...
static bool isRecordType(QualType T)
static CharSourceRange getRange(const CharSourceRange &EditRange, const SourceManager &SM, const LangOptions &LangOpts, bool IncludeMacroExpansion)
Defines the SourceManager interface.
const NestedNameSpecifier * Specifier
RAII object that pops an ExpressionEvaluationContext when exiting a function body.
ExitFunctionBodyRAII(Sema &S, bool IsLambda)
llvm::APInt getValue() const
virtual void HandleTagDeclDefinition(TagDecl *D)
HandleTagDeclDefinition - This callback is invoked each time a TagDecl (e.g.
virtual void HandleInlineFunctionDefinition(FunctionDecl *D)
This callback is invoked each time an inline (method or friend) function definition in a class is com...
virtual bool shouldSkipFunctionBody(Decl *D)
This callback is called for each function if the Parser was initialized with SkipFunctionBodies set t...
virtual void AssignInheritanceModel(CXXRecordDecl *RD)
Callback invoked when an MSInheritanceAttr has been attached to a CXXRecordDecl.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
QualType getUsingType(const UsingShadowDecl *Found, QualType Underlying) const
SourceManager & getSourceManager()
TranslationUnitDecl * getTranslationUnitDecl() const
const ConstantArrayType * getAsConstantArrayType(QualType T) const
QualType getParenType(QualType NamedType) const
unsigned getIntWidth(QualType T) const
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType) const
ExternCContextDecl * getExternCContextDecl() const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl.
DeclarationNameTable DeclarationNames
QualType getObjCClassType() const
Represents the Objective-C Class type.
QualType getRecordType(const RecordDecl *Decl) const
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
void setObjCIdRedefinitionType(QualType RedefType)
Set the user-written type that redefines id.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateName Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl)
Set the type for the C sigjmp_buf type.
bool DeclMustBeEmitted(const Decl *D)
Determines if the decl can be CodeGen'ed or deserialized from PCH lazily, only when used; this is onl...
void setObjCSelRedefinitionType(QualType RedefType)
Set the user-written type that redefines 'SEL'.
void setFILEDecl(TypeDecl *FILEDecl)
Set the type for the C FILE type.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
const IncompleteArrayType * getAsIncompleteArrayType(QualType T) const
const CXXMethodDecl * getCurrentKeyFunction(const CXXRecordDecl *RD)
Get our current best idea for the key function of the given record decl, or nullptr if there isn't on...
bool hasSameFunctionTypeIgnoringExceptionSpec(QualType T, QualType U) const
Determine whether two function types are the same, ignoring exception specifications in cases where t...
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
Builtin::Context & BuiltinInfo
void addModuleInitializer(Module *M, Decl *Init)
Add a declaration to the list of declarations that are initialized for a module.
const LangOptions & getLangOpts() const
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
void attachCommentsToJustParsedDecls(ArrayRef< Decl * > Decls, const Preprocessor *PP)
Searches existing comments for doc comments that should be attached to Decls.
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
QualType getObjCSelType() const
Retrieve the type that corresponds to the predefined Objective-C 'SEL' type.
QualType getDeducedTemplateSpecializationType(TemplateName Template, QualType DeducedType, bool IsDependent) const
C++17 deduced class template specialization type.
GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD) const
void setucontext_tDecl(TypeDecl *ucontext_tDecl)
Set the type for the C ucontext_t type.
CanQualType UnsignedLongTy
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
MangleNumberingContext & getManglingNumberContext(const DeclContext *DC)
Retrieve the context for computing mangling numbers in the given DeclContext.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType, TagDecl *OwnedTagDecl=nullptr) const
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
void setNonKeyFunction(const CXXMethodDecl *method)
Observe that the given method cannot be a key function.
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
const clang::PrintingPolicy & getPrintingPolicy() const
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool BlockReturnType=false, bool IsConditionalOperator=false)
QualType getObjCIdType() const
Represents the Objective-CC id type.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
void setManglingNumber(const NamedDecl *ND, unsigned Number)
CanQualType UnsignedCharTy
CanQualType UnsignedIntTy
void addDeclaratorForUnnamedTagDecl(TagDecl *TD, DeclaratorDecl *DD)
CanQualType UnsignedLongLongTy
QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error, unsigned *IntegerConstantArgs=nullptr) const
Return the type for the specified builtin.
CanQualType UnsignedShortTy
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
void setcudaConfigureCallDecl(FunctionDecl *FD)
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
const VariableArrayType * getAsVariableArrayType(QualType T) const
void setObjCClassRedefinitionType(QualType RedefType)
Set the user-written type that redefines 'SEL'.
bool hasDirectOwnershipQualifier(QualType Ty) const
Return true if the type has been explicitly qualified with ObjC ownership.
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
void ResetObjCLayout(const ObjCContainerDecl *CD)
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
const TargetInfo & getTargetInfo() const
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
void getFunctionFeatureMap(llvm::StringMap< bool > &FeatureMap, const FunctionDecl *) const
QualType getLifetimeQualifiedType(QualType type, Qualifiers::ObjCLifetime lifetime)
Return a type with the given lifetime qualifier.
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
void setjmp_bufDecl(TypeDecl *jmp_bufDecl)
Set the type for the C jmp_buf type.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
QualType mergeObjCGCQualifiers(QualType, QualType)
mergeObjCGCQualifiers - This routine merges ObjC's GC attribute of 'LHS' and 'RHS' attributes and ret...
bool isPromotableIntegerType(QualType T) const
More type predicates useful for type checking/promotion.
LangAS getLangASForBuiltinAddressSpace(unsigned AS) const
bool hasSameFunctionTypeIgnoringPtrSizes(QualType T, QualType U)
Determine whether two function types are the same, ignoring pointer sizes in the return type and para...
TemplateName getAssumedTemplateName(DeclarationName Name) const
Retrieve a template name representing an unqualified-id that has been assumed to name a template for ...
@ GE_Missing_stdio
Missing a type from <stdio.h>
@ GE_Missing_type
Missing a type.
@ GE_Missing_ucontext
Missing a type from <ucontext.h>
@ GE_Missing_setjmp
Missing a type from <setjmp.h>
void addTypedefNameForUnnamedTagDecl(TagDecl *TD, TypedefNameDecl *TND)
unsigned getTypeAlign(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in bits.
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc.
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons.
Wrapper for source info for arrays.
SourceLocation getLBracketLoc() const
Expr * getSizeExpr() const
TypeLoc getElementLoc() const
SourceLocation getRBracketLoc() const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getElementType() const
Attr - This represents one attribute.
attr::Kind getKind() const
Attr * clone(ASTContext &C) const
SourceLocation getLocation() const
@ AS_Declspec
__declspec(...)
SourceRange getRange() const
A factory, from which one makes pools, from which one creates individual attributes which are dealloc...
AttributeFactory & getFactory() const
Type source information for an attributed type.
TypeLoc getModifiedLoc() const
The modified type, which is generally canonically different from the attribute type.
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condnition evaluates to false;...
Expr * getCond() const
getCond - Return the condition expression; this is defined in terms of the opaque value.
A builtin binary operation expression such as "x + y" or "x <= y".
static bool isCompoundAssignmentOp(Opcode Opc)
A binding in a decomposition declaration.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
bool doesNotEscape() const
This class is used for builtin types like 'int'.
Holds information about both target-independent and target-specific builtins, allowing easy queries b...
bool performsCallback(unsigned ID, llvm::SmallVectorImpl< int > &Encoding) const
Determine whether this builtin has callback behavior (see llvm::AbstractCallSites for details).
bool isAuxBuiltinID(unsigned ID) const
Return true if builtin ID belongs to AuxTarget.
const char * getHeaderName(unsigned ID) const
If this is a library function that comes from a specific header, retrieve that header name.
llvm::StringRef getName(unsigned ID) const
Return the identifier name for the specified builtin, e.g.
bool isReturnsTwice(unsigned ID) const
Return true if we know this builtin can return twice.
bool isConstWithoutErrnoAndExceptions(unsigned ID) const
Return true if this function has no side effects and doesn't read memory, except for possibly errno o...
bool allowTypeMismatch(unsigned ID) const
Determines whether a declaration of this builtin should be recognized even if the type doesn't match ...
bool isTSBuiltin(unsigned ID) const
Return true if this function is a target-specific builtin.
bool isHeaderDependentFunction(unsigned ID) const
Returns true if this builtin requires appropriate header in other compilers.
bool isScanfLike(unsigned ID, unsigned &FormatIdx, bool &HasVAListArg)
Determine whether this builtin is like scanf in its formatting rules and, if so, set the index to the...
bool isInStdNamespace(unsigned ID) const
Determines whether this builtin is a C++ standard library function that lives in (possibly-versioned)...
bool isPredefinedLibFunction(unsigned ID) const
Determines whether this builtin is a predefined libc/libm function, such as "malloc",...
bool isPrintfLike(unsigned ID, unsigned &FormatIdx, bool &HasVAListArg)
Determine whether this builtin is like printf in its formatting rules and, if so, set the index to th...
bool isConstWithoutExceptions(unsigned ID) const
bool isPredefinedRuntimeFunction(unsigned ID) const
Determines whether this builtin is a predefined compiler-rt/libgcc function, such as "__clear_cache",...
bool isPure(unsigned ID) const
Return true if this function has no side effects.
bool isNoThrow(unsigned ID) const
Return true if we know this builtin never throws an exception.
bool isConst(unsigned ID) const
Return true if this function has no side effects and doesn't read memory.
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
Represents a base class of a C++ class.
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getEndLoc() const LLVM_READONLY
Represents a call to a C++ constructor.
bool isElidable() const
Whether this construction is elidable.
Expr * getArg(unsigned Arg)
Return the specified argument.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
Represents a C++ constructor within a class.
bool isCopyConstructor(unsigned &TypeQuals) const
Whether this constructor is a copy constructor (C++ [class.copy]p2, which can be used to copy the cla...
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, ExplicitSpecifier ES, bool UsesFPIntrin, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, InheritedConstructor Inherited=InheritedConstructor(), Expr *TrailingRequiresClause=nullptr)
Represents a C++ conversion function within a class.
static CXXConversionDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool UsesFPIntrin, bool isInline, ExplicitSpecifier ES, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, Expr *TrailingRequiresClause=nullptr)
static CXXDeductionGuideDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, ExplicitSpecifier ES, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, SourceLocation EndLocation, CXXConstructorDecl *Ctor=nullptr, DeductionCandidate Kind=DeductionCandidate::Normal)
Represents a C++ destructor within a class.
static CXXDestructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool UsesFPIntrin, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, Expr *TrailingRequiresClause=nullptr)
A mapping from each virtual member function to its set of final overriders.
Represents a static or instance method of a struct/union/class.
void addOverriddenMethod(const CXXMethodDecl *MD)
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
QualType getThisType() const
Return the type of the this pointer.
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
static CXXMethodDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin, bool isInline, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, Expr *TrailingRequiresClause=nullptr)
Qualifiers getMethodQualifiers() const
bool isCopyAssignmentOperator() const
Determine whether this is a copy-assignment operator, regardless of whether it was declared implicitl...
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
A call to an overloaded operator written using operator syntax.
Represents a C++ struct/union/class.
bool hasNonTrivialCopyAssignment() const
Determine whether this class has a non-trivial copy assignment operator (C++ [class....
bool hasTrivialDefaultConstructor() const
Determine whether this class has a trivial default constructor (C++11 [class.ctor]p5).
base_class_iterator bases_end()
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
const FunctionDecl * isLocalClass() const
If the class is a local class [class.local], returns the enclosing function declaration.
bool hasNonTrivialDestructor() const
Determine whether this class has a non-trivial destructor (C++ [class.dtor]p3)
CXXRecordDecl * getDefinition() const
unsigned getNumBases() const
Retrieves the number of base classes of this class.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr, bool DelayTypeCreation=false)
bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths &Paths, bool LookupInDependent=false) const
Look for entities within the base classes of this C++ class, transitively searching all base class su...
base_class_iterator bases_begin()
capture_const_range captures() const
bool hasDefinition() const
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
LambdaCaptureDefault getLambdaCaptureDefault() const
void setDescribedClassTemplate(ClassTemplateDecl *Template)
bool hasNonTrivialCopyConstructor() const
Determine whether this class has a non-trivial copy constructor (C++ [class.copy]p6,...
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Represents a C++ nested-name-specifier or a global scope specifier.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
char * location_data() const
Retrieve the data associated with the source-location information.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
SourceRange getRange() const
SourceLocation getBeginLoc() const
bool isSet() const
Deprecated.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
bool isEmpty() const
No scope specifier.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
bool isCallToStdMove() const
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
CastKind getCastKind() const
static CharSourceRange getCharRange(SourceRange R)
CharUnits - This is an opaque type for sizes expressed in character units.
bool isZero() const
isZero - Test whether the quantity equals zero.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Declaration of a function specialization at template class scope.
static ClassScopeFunctionSpecializationDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, CXXMethodDecl *FD, bool HasExplicitTemplateArgs, const TemplateArgumentListInfo &TemplateArgs)
Declaration of a class template.
ConditionalOperator - The ?: ternary operator.
const llvm::APInt & getSize() const
static unsigned getNumAddressingBits(const ASTContext &Context, QualType ElementType, const llvm::APInt &NumElements)
Determine the number of bits required to address a member of.
static unsigned getMaxSizeBits(const ASTContext &Context)
Determine the maximum number of active bits that an array's size can require, which limits the maximu...
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
The results of name lookup within a DeclContext.
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
bool isFileContext() const
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
bool isObjCContainer() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
const BlockDecl * getInnermostBlockDecl() const
Return this DeclContext if it is a BlockDecl.
bool isTranslationUnit() const
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
void removeDecl(Decl *D)
Removes a declaration from this context.
void addDecl(Decl *D)
Add the declaration D into this context.
bool containsDecl(Decl *D) const
Checks whether a declaration is in this context.
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
bool isFunctionOrMethod() const
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
Decl::Kind getDeclKind() const
DeclContext * getNonTransparentContext()
Simple template class for restricting typo correction candidates to ones having a single Decl* of the...
static DeclGroupRef Create(ASTContext &C, Decl **Decls, unsigned NumDecls)
A reference to a declared variable, function, enum, etc.
SourceLocation getBeginLoc() const LLVM_READONLY
Captures information about "declaration specifiers".
bool isVirtualSpecified() const
bool isModulePrivateSpecified() const
static const TST TST_typeof_unqualType
bool hasAutoTypeSpec() const
static const TST TST_typename
bool SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
These methods set the specified attribute of the DeclSpec and return false if there was no error.
void ClearStorageClassSpecs()
bool isNoreturnSpecified() const
TST getTypeSpecType() const
SourceLocation getStorageClassSpecLoc() const
SCS getStorageClassSpec() const
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
SourceLocation getBeginLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
void SetRangeEnd(SourceLocation Loc)
static const TST TST_interface
static const TST TST_typeofExpr
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
void SetRangeStart(SourceLocation Loc)
SourceLocation getNoreturnSpecLoc() const
bool isExternInLinkageSpec() const
static const TST TST_union
SCS
storage-class-specifier
SourceLocation getExplicitSpecLoc() const
SourceLocation getModulePrivateSpecLoc() const
bool isMissingDeclaratorOk()
Checks if this DeclSpec can stand alone, without a Declarator.
ParsedType getRepAsType() const
void UpdateTypeRep(ParsedType Rep)
TSCS getThreadStorageClassSpec() const
ParsedAttributes & getAttributes()
void ClearTypeQualifiers()
Clear out all of the type qualifiers.
SourceLocation getConstSpecLoc() const
SourceRange getExplicitSpecRange() const
Expr * getRepAsExpr() const
static const TST TST_enum
static const TST TST_decltype
static bool isDeclRep(TST T)
bool isInlineSpecified() const
SourceLocation getRestrictSpecLoc() const
static const TST TST_typeof_unqualExpr
static const TST TST_class
void ClearConstexprSpec()
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
static const TST TST_atomic
SourceLocation getThreadStorageClassSpecLoc() const
Decl * getRepAsDecl() const
static const TST TST_unspecified
SourceLocation getAtomicSpecLoc() const
SourceLocation getVirtualSpecLoc() const
SourceLocation getConstexprSpecLoc() const
CXXScopeSpec & getTypeSpecScope()
SourceLocation getTypeSpecTypeLoc() const
void UpdateExprRep(Expr *Rep)
static const TSCS TSCS_thread_local
static const TST TST_error
ExplicitSpecifier getExplicitSpecifier() const
bool isTypeSpecOwned() const
SourceLocation getInlineSpecLoc() const
SourceLocation getUnalignedSpecLoc() const
SourceLocation getVolatileSpecLoc() const
FriendSpecified isFriendSpecified() const
bool hasExplicitSpecifier() const
bool hasConstexprSpecifier() const
static const TST TST_typeofType
static const TST TST_auto
ConstexprSpecKind getConstexprSpecifier() const
static const TST TST_struct
Decl - This represents one declaration (or definition), e.g.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
const DeclContext * getParentFunctionOrMethod(bool LexicalParent=false) const
If this decl is defined inside a function/method/block it returns the corresponding DeclContext,...
bool isInStdNamespace() const
SourceLocation getEndLoc() const LLVM_READONLY
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
void setAttrs(const AttrVec &Attrs)
bool isUnavailable(std::string *Message=nullptr) const
Determine whether this declaration is marked 'unavailable'.
void setLocalExternDecl()
Changes the namespace of this declaration to reflect that it's a function-local extern declaration.
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
Module * getOwningModuleForLinkage(bool IgnoreLinkage=false) const
Get the module that owns this declaration for linkage purposes.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
void setTopLevelDeclInObjCContainer(bool V=true)
bool isInIdentifierNamespace(unsigned NS) const
@ FOK_Undeclared
A friend of a previously-undeclared entity.
@ FOK_None
Not a friend object.
@ FOK_Declared
A friend of a previously-declared entity.
bool isTemplated() const
Determine whether this declaration is a templated entity (whether it is.
bool isInExportDeclContext() const
Whether this declaration was exported in a lexical context.
bool isReferenced() const
Whether any declaration of this entity was referenced.
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
@ OBJC_TQ_CSNullability
The nullability qualifier is set when the nullability of the result or parameter was expressed via a ...
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration.
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
bool isInvalidDecl() const
bool isLocalExternDecl() const
Determine whether this is a block-scope declaration with linkage.
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
void setAccess(AccessSpecifier AS)
SourceLocation getLocation() const
@ IDNS_Ordinary
Ordinary names.
void setLocalOwningModule(Module *M)
void setImplicit(bool I=true)
void setIsUsed()
Set whether the declaration is used, in the sense of odr-use.
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required.
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
SourceLocation getBeginLoc() const LLVM_READONLY
bool hasOwningModule() const
Is this declaration owned by some module?
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
void setNonMemberOperator()
Specifies that this declaration is a C++ overloaded non-member.
void setLexicalDeclContext(DeclContext *DC)
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
The name of a declaration.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
@ CXXConversionFunctionName
Represents a ValueDecl that came out of a declarator.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
SourceLocation getOuterLocStart() const
Return start of source range taking into account any outer template declarations.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
SourceLocation getTypeSpecStartLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
unsigned getNumTemplateParameterLists() const
void setTypeSourceInfo(TypeSourceInfo *TI)
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
Expr * getTrailingRequiresClause()
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
TypeSourceInfo * getTypeSourceInfo() const
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
Information about one declarator, including the parsed type information and the identifier.
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
void SetIdentifier(IdentifierInfo *Id, SourceLocation IdLoc)
Set the name of this declarator to be the given identifier.
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
Expr * getAsmLabel() const
FunctionDefinitionKind getFunctionDefinitionKind() const
const ParsedAttributes & getAttributes() const
void setRedeclaration(bool Val)
SourceLocation getIdentifierLoc() const
SourceLocation getEndLoc() const LLVM_READONLY
Expr * getTrailingRequiresClause()
Sets a trailing requires clause for this declarator.
void setInvalidType(bool Val=true)
TemplateParameterList * getInventedTemplateParameterList() const
The template parameter list generated from the explicit template parameters along with any invented t...
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
bool isRedeclaration() const
const ParsedAttributesView & getDeclarationAttributes() const
const DecompositionDeclarator & getDecompositionDeclarator() const
SourceLocation getBeginLoc() const LLVM_READONLY
bool isCtorOrDtor()
Returns true if this declares a constructor or a destructor.
bool isFunctionDefinition() const
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
bool hasInitializer() const
void setFunctionDefinitionKind(FunctionDefinitionKind Val)
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
void takeAttributes(ParsedAttributes &attrs)
takeAttributes - Takes attributes from the given parsed-attributes set and add them to this declarato...
IdentifierInfo * getIdentifier() const
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &&attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
bool isInvalidType() const
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
bool isDecompositionDeclarator() const
Return whether this declarator is a decomposition declarator.
bool isFirstDeclarationOfMember()
Returns true if this declares a real member and not a friend.
bool isStaticMember()
Returns true if this declares a static member.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
A decomposition declaration.
static DecompositionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation LSquareLoc, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< BindingDecl * > Bindings)
A parsed C++17 decomposition declarator of the form '[' identifier-list ']'.
SourceRange getSourceRange() const
SourceLocation getLSquareLoc() const
void setNameLoc(SourceLocation Loc)
void setElaboratedKeywordLoc(SourceLocation Loc)
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Concrete class used by the front-end to report problems and issues.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
Level getDiagnosticLevel(unsigned DiagID, SourceLocation Loc) const
Based on the way the client configured the DiagnosticsEngine object, classify the specified diagnosti...
void setElaboratedKeywordLoc(SourceLocation Loc)
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
An instance of this object exists for each enum constant that is defined.
static EnumConstantDecl * Create(ASTContext &C, EnumDecl *DC, SourceLocation L, IdentifierInfo *Id, QualType T, Expr *E, const llvm::APSInt &V)
const Expr * getInitExpr() const
const llvm::APSInt & getInitVal() const
enumerator_range enumerators() const
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
void setIntegerType(QualType T)
Set the underlying integer type.
void setIntegerTypeSourceInfo(TypeSourceInfo *TInfo)
Set the underlying integer type source info.
bool isComplete() const
Returns true if this can be considered a complete type.
static EnumDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, EnumDecl *PrevDecl, bool IsScoped, bool IsScopedUsingClassTag, bool IsFixed)
bool isClosedFlag() const
Returns true if this enum is annotated with flag_enum and isn't annotated with enum_extensibility(ope...
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
SourceRange getIntegerTypeRange() const LLVM_READONLY
Retrieve the source range that covers the underlying type if specified.
void setPromotionType(QualType T)
Set the promotion type.
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
EvaluatedExprVisitor - This class visits 'Expr *'s.
Store information needed for an explicit specifier.
This represents one expression.
bool EvaluateAsInt(EvalResult &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects, bool InConstantContext=false) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer,...
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
bool isValueDependent() const
Determines whether the value of this expression depends on.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
bool containsErrors() const
Whether this expression contains subexpressions which had errors, e.g.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point.
bool isConstantInitializer(ASTContext &Ctx, bool ForRef, const Expr **Culprit=nullptr) const
isConstantInitializer - Returns true if this expression can be emitted to IR as a constant,...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Represents difference between two FPOptions values.
bool isFPConstrained() const
Represents a member of a struct/union/class.
bool isBitField() const
Determines whether this field is a bitfield.
bool isAnonymousStructOrUnion() const
Determines whether this field is a representative for an anonymous struct or union.
bool isZeroLengthBitField(const ASTContext &Ctx) const
Is this a zero-length bit-field? Such bit-fields aren't really bit-fields at all and instead act as a...
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
static FieldDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle)
static FileScopeAsmDecl * Create(ASTContext &C, DeclContext *DC, StringLiteral *Str, SourceLocation AsmLoc, SourceLocation RParenLoc)
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
Represents a function declaration or definition.
bool isMultiVersion() const
True if this function is considered a multiversioned function.
const ParmVarDecl * getParamDecl(unsigned i) const
bool isPure() const
Whether this virtual function is pure, i.e.
ConstexprSpecKind getConstexprKind() const
void setPreviousDeclaration(FunctionDecl *PrevDecl)
void setDescribedFunctionTemplate(FunctionTemplateDecl *Template)
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
void setFriendConstraintRefersToEnclosingTemplate(bool V=true)
void setHasSkippedBody(bool Skipped=true)
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type.
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
param_iterator param_end()
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
void setIsMultiVersion(bool V=true)
Sets the multiversion state for this declaration and all of its redeclarations.
QualType getReturnType() const
ArrayRef< ParmVarDecl * > parameters() const
bool isCPUSpecificMultiVersion() const
True if this function is a multiversioned processor specific function as a part of the cpu_specific/c...
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
LanguageLinkage getLanguageLinkage() const
Compute the language linkage.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
bool hasWrittenPrototype() const
Whether this function has a written prototype.
void setWillHaveBody(bool V=true)
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
param_iterator param_begin()
bool isVariadic() const
Whether this function is variadic.
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
bool isDeleted() const
Whether this function has been deleted.
bool isMSVCRTEntryPoint() const
Determines whether this function is a MSVCRT user defined entry point.
void setPure(bool P=true)
bool isTemplateInstantiation() const
Determines if the given function was instantiated from a function template.
@ TK_MemberSpecialization
StorageClass getStorageClass() const
Returns the storage class as written in the source.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a member function.
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
void setHasInheritedPrototype(bool P=true)
State that this function inherited its prototype from a previous declaration.
bool isExternC() const
Determines whether this function is a function with external, C linkage.
bool isLateTemplateParsed() const
Whether this templated function will be late parsed.
bool hasImplicitReturnZero() const
Whether falling off this function implicitly returns null/zero.
bool isImmediateEscalating() const
void setVirtualAsWritten(bool V)
State that this function is marked as virtual explicitly.
bool hasSkippedBody() const
True if the function was a definition but its body was skipped.
FunctionDecl * getDefinition()
Get the definition for this declaration.
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program.
void setImplicitlyInline(bool I=true)
Flag that this function is implicitly inline.
bool isReplaceableGlobalAllocationFunction(std::optional< unsigned > *AlignmentParam=nullptr, bool *IsNothrow=nullptr) const
Determines whether this function is one of the replaceable global allocation functions: void *operato...
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin=false, bool isInlineSpecified=false, bool hasWrittenPrototype=true, ConstexprSpecKind ConstexprKind=ConstexprSpecKind::Unspecified, Expr *TrailingRequiresClause=nullptr)
bool isThisDeclarationInstantiatedFromAFriendDefinition() const
Determine whether this specific declaration of the function is a friend declaration that was instanti...
void setRangeEnd(SourceLocation E)
bool isCPUDispatchMultiVersion() const
True if this function is a multiversioned dispatch function as a part of the cpu_specific/cpu_dispatc...
bool isDefaulted() const
Whether this function is defaulted.
void setIneligibleOrNotSelected(bool II)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isOverloadedOperator() const
Whether this function declaration represents an C++ overloaded operator, e.g., "operator+".
const IdentifierInfo * getLiteralIdentifier() const
getLiteralIdentifier - The literal suffix identifier this function represents, if any.
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any.
void setConstexprKind(ConstexprSpecKind CSK)
void setDefaulted(bool D=true)
QualType getDeclaredReturnType() const
Get the declared return type, which may differ from the actual return type if the return type is dedu...
bool isGlobal() const
Determines whether this is a global function.
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
bool hasInheritedPrototype() const
Whether this function inherited its prototype from a previous declaration.
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization,...
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
DeclarationNameInfo getNameInfo() const
void setDeletedAsWritten(bool D=true)
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
void setHasImplicitReturnZero(bool IRZ)
State that falling off this function implicitly returns null/zero.
bool isDefined(const FunctionDecl *&Definition, bool CheckForPendingFriendDefinition=false) const
Returns true if the function has a definition that does not need to be instantiated.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
MultiVersionKind getMultiVersionKind() const
Gets the kind of multiversioning attribute this declaration has.
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
Represents a prototype with parameter type info, e.g.
unsigned getNumParams() const
QualType getParamType(unsigned i) const
bool hasExceptionSpec() const
Return whether this function has any kind of exception spec.
bool isVariadic() const
Whether this function prototype is variadic.
ExtProtoInfo getExtProtoInfo() const
ArrayRef< QualType > getParamTypes() const
Declaration of a template function.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
FunctionTemplateDecl * getInstantiatedFromMemberTemplate() const
FunctionTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this function template, or nullptr if no such declaration exists...
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
void mergePrevDecl(FunctionTemplateDecl *Prev)
Merge Prev with our RedeclarableTemplateDecl::Common.
Provides information about a function template specialization, which is a FunctionDecl that has been ...
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
Wrapper for source info for functions.
A class which abstracts out some details necessary for making a call.
ExtInfo withCallingConv(CallingConv cc) const
CallingConv getCC() const
ExtInfo withProducesResult(bool producesResult) const
unsigned getRegParm() const
bool getNoCallerSavedRegs() const
ExtInfo withNoReturn(bool noReturn) const
bool getHasRegParm() const
bool getProducesResult() const
ExtInfo withNoCallerSavedRegs(bool noCallerSavedRegs) const
ExtInfo withRegParm(unsigned RegParm) const
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
static StringRef getNameForCallConv(CallingConv CC)
unsigned getRegParmType() const
CallingConv getCallConv() const
QualType getReturnType() const
bool getCmseNSCallAttr() const
One of these records is kept for each identifier that is lexed.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
bool isEditorPlaceholder() const
Return true if this identifier is an editor placeholder.
StringRef getName() const
Return the actual identifier string.
iterator - Iterate over the decls of a specified declaration name.
iterator begin(DeclarationName Name)
Returns an iterator over decls with the name 'Name'.
void RemoveDecl(NamedDecl *D)
RemoveDecl - Unlink the decl from its shadowed decl chain.
void InsertDeclAfter(iterator Pos, NamedDecl *D)
Insert the given declaration after the given iterator position.
iterator end()
Returns the end iterator.
void AddDecl(NamedDecl *D)
AddDecl - Link the decl to its shadowed decl chain.
bool isDeclInScope(Decl *D, DeclContext *Ctx, Scope *S=nullptr, bool AllowInlineNamespace=false) const
isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true if 'D' is in Scope 'S',...
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
Represents a C array with an unspecified size.
Represents a field injected from an anonymous union/struct into the parent scope.
static IndirectFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, llvm::MutableArrayRef< NamedDecl * > CH)
void setInherited(bool I)
Description of a constructor that was inherited from a base class.
Describes an C or C++ initializer list.
Describes the kind of initialization being performed, along with location information for tokens rela...
static InitializationKind CreateDefault(SourceLocation InitLoc)
Create a default initialization.
static InitializationKind CreateForInit(SourceLocation Loc, bool DirectInit, Expr *Init)
Create an initialization from an initializer (which, for direct initialization from a parenthesized l...
Describes the sequence of initializations required to initialize a given object or reference with a s...
step_iterator step_begin() const
ExprResult Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
Perform the actual initialization of the given entity based on the computed initialization sequence.
@ SK_ParenthesizedListInit
Initialize an aggreagate with parenthesized list of values.
Describes an entity that is being initialized.
static InitializedEntity InitializeVariable(VarDecl *Var)
Create the initialization entity for a variable.
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Represents the declaration of a label.
bool isResolvedMSAsmLabel() const
LabelStmt * getStmt() const
bool isMSAsmLabel() const
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const
FPExceptionModeKind getDefaultExceptionMode() const
bool requiresStrictPrototypes() const
Returns true if functions without prototypes or functions with an identifier list (aka K&R C function...
clang::ObjCRuntime ObjCRuntime
std::string getOpenCLVersionString() const
Return the OpenCL C or C++ for OpenCL language name and version as a string.
bool IsHeaderFile
Indicates whether the front-end is explicitly told that the input is a header file (i....
bool implicitFunctionsAllowed() const
Returns true if implicit function declarations are allowed in the current language mode.
@ FPE_Ignore
Assume that floating-point exceptions are masked.
unsigned getOpenCLCompatibleVersion() const
Return the OpenCL version that kernel language is compatible with.
std::vector< llvm::Triple > OMPTargetTriples
Triples of the OpenMP targets that the host code codegen should take into account in order to generat...
void push_back(const T &LocalValue)
static SourceLocation findLocationAfterToken(SourceLocation loc, tok::TokenKind TKind, const SourceManager &SM, const LangOptions &LangOpts, bool SkipTrailingWhitespaceAndNewLine)
Checks that the given token is the first token that occurs after the given location (this excludes co...
Represents a linkage specification.
static LinkageSpecDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation ExternLoc, SourceLocation LangLoc, LanguageIDs Lang, bool HasBraces)
void InstantiatedLocal(const Decl *D, Decl *Inst)
A class for iterating through a result set and possibly filtering out results.
void erase()
Erase the last element returned from this iterator.
Represents the results of name lookup.
@ FoundOverloaded
Name lookup found a set of overloaded functions that met the criteria.
@ FoundUnresolvedValue
Name lookup found an unresolvable value declaration and cannot yet complete.
@ Ambiguous
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
@ NotFound
No entity found met the criteria.
@ NotFoundInCurrentInstantiation
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
@ Found
Name lookup found a single declaration that met the criteria.
DeclClass * getAsSingle() const
bool empty() const
Return true if no decls were found.
SourceLocation getNameLoc() const
Gets the location of the identifier.
Filter makeFilter()
Create a filter for this result set.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
Sema & getSema() const
Get the Sema object that this lookup result is searching with.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
LookupResultKind getResultKind() const
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
DeclarationName getLookupName() const
Gets the name to look up.
@ AmbiguousTagHiding
Name lookup results in an ambiguity because an entity with a tag name was hidden by an entity with an...
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
virtual unsigned getManglingNumber(const CXXMethodDecl *CallOperator)=0
Retrieve the mangling number of a new lambda expression with the given call operator within this cont...
virtual unsigned getStaticLocalNumber(const VarDecl *VD)=0
Static locals are numbered by source order.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
A pointer to member type per C++ 8.3.3 - Pointers to members.
Describes a module or submodule.
SourceLocation DefinitionLoc
The location of the module definition.
Module * Parent
The parent of this module.
bool isPrivateModule() const
bool isModulePurview() const
Does this Module scope describe part of the purview of a standard named C++ module?
bool isHeaderLikeModule() const
Is this module have similar semantics as headers.
bool isModuleImplementation() const
Is this a module implementation.
StringRef getPrimaryModuleInterfaceName() const
Get the primary module interface name from a partition.
bool isModulePartition() const
Is this a module partition.
bool isGlobalModule() const
Does this Module scope describe a fragment of the global module within some C++ module.
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
Module * getTopLevelModule()
Retrieve the top-level module for this (sub)module, which may be this module.
This represents a decl that may have a name.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
bool isLinkageValid() const
True if the computed linkage is valid.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Visibility getVisibility() const
Determines the visibility of this entity.
bool hasLinkageBeenComputed() const
True if something has required us to compute the linkage of this declaration.
bool hasExternalFormalLinkage() const
True if this decl has external linkage.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
bool declarationReplaces(NamedDecl *OldD, bool IsKnownNewer=true) const
Determine whether this declaration, if known to be well-formed within its context,...
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined.
bool hasLinkage() const
Determine whether this declaration has linkage.
bool isExternallyVisible() const
ReservedIdentifierStatus isReserved(const LangOptions &LangOpts) const
Determine if the declaration obeys the reserved identifier rules of the given language.
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
Represent a C++ namespace.
bool isAnonymousNamespace() const
Returns true if this is an anonymous namespace declaration.
Class that aids in the construction of nested-name-specifiers along with source-location information ...
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
A C++ nested-name-specifier augmented with source location information.
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
bool containsErrors() const
Whether this nested name specifier contains an error.
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
static NestedNameSpecifier * GlobalSpecifier(const ASTContext &Context)
Returns the nested name specifier representing the global scope.
@ Super
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
ObjCCategoryDecl - Represents a category declaration.
ObjCCompatibleAliasDecl - Represents alias of a class.
ObjCContainerDecl - Represents a container for method declarations.
ObjCIvarDecl * getIvarDecl(IdentifierInfo *Id) const
getIvarDecl - This method looks up an ivar in this ContextDecl.
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Represents an ObjC class declaration.
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
known_extensions_range known_extensions() const
ObjCIvarDecl - Represents an ObjC instance variable.
static ObjCIvarDecl * Create(ASTContext &C, ObjCContainerDecl *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, AccessControl ac, Expr *BW=nullptr, bool synthesized=false)
An expression that sends a message to the given Objective-C object or class.
ObjCMethodDecl - Represents an instance or class method declaration.
param_const_iterator param_end() const
param_const_iterator param_begin() const
const ParmVarDecl *const * param_const_iterator
ParmVarDecl *const * param_iterator
bool isNonFragile() const
Does this runtime follow the set of implied behaviors for a "non-fragile" ABI?
bool isFragile() const
The inverse of isNonFragile(): does this runtime follow the set of implied behaviors for a "fragile" ...
Wrapper for void* pointer.
static OpaquePtr make(PtrTy P)
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
bool isAvailableOption(llvm::StringRef Ext, const LangOptions &LO) const
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13....
@ CSK_Normal
Normal lookup.
SmallVectorImpl< OverloadCandidate >::iterator iterator
void NoteCandidates(PartialDiagnosticAt PA, Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, StringRef Opc="", SourceLocation Loc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;})
When overload resolution fails, prints diagnostic messages containing the candidates in the candidate...
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best)
Find the best viable function on this overload set, if it exists.
MapType::iterator iterator
SmallVectorImpl< UniqueVirtualMethod >::iterator overriding_iterator
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
unsigned getNumExprs() const
Return the number of expressions in this paren list.
void setRParenLoc(SourceLocation Loc)
TypeLoc getInnerLoc() const
void setLParenLoc(SourceLocation Loc)
Sugar for parentheses used when specifying types.
Represents a parameter to a function.
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
ObjCDeclQualifier getObjCDeclQualifier() const
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
QualType getOriginalType() const
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
ParsedAttr - Represents a syntactic attribute.
static const ParsedAttributesView & none()
bool hasAttribute(ParsedAttr::Kind K) const
ParsedAttributes - A collection of parsed attributes.
AttributePool & getPool() const
unsigned getDiagID() const
TypeLoc getPointeeLoc() const
Wrapper for source info for pointers.
void setStarLoc(SourceLocation Loc)
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
bool isCodeCompletionEnabled() const
Determine if we are performing code completion.
HeaderSearch & getHeaderSearchInfo() const
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
StringRef getLastMacroWithSpelling(SourceLocation Loc, ArrayRef< TokenValue > Tokens) const
Return the name of the macro defined before Loc that has spelling Tokens.
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool hasNonTrivialToPrimitiveCopyCUnion() const
Check if this is or contains a C union that is non-trivial to copy, which is a union that has a membe...
PrimitiveDefaultInitializeKind
bool isNonWeakInMRRWithObjCWeak(const ASTContext &Context) const
const IdentifierInfo * getBaseTypeIdentifier() const
Retrieves a pointer to the name of the base type.
QualType withoutLocalFastQualifiers() const
QualType getDesugaredType(const ASTContext &Context) const
Return the specified type with any "sugar" removed from the type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
PrimitiveCopyKind isNonTrivialToPrimitiveCopy() const
Check if this is a non-trivial type that would cause a C struct transitively containing this type to ...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
LangAS getAddressSpace() const
Return the address space of this type.
bool hasNonTrivialToPrimitiveDestructCUnion() const
Check if this is or contains a C union that is non-trivial to destruct, which is a union that has a m...
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
PrimitiveDefaultInitializeKind isNonTrivialToPrimitiveDefaultInitialize() const
Functions to query basic properties of non-trivial C struct types.
bool isObjCGCStrong() const
true when Type is objc's strong.
bool isConstQualified() const
Determine whether this type is const-qualified.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after.
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the type.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
bool hasNonTrivialObjCLifetime() const
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
@ PCK_Trivial
The type does not fall into any of the following categories.
@ PCK_VolatileTrivial
The type would be trivial except that it is volatile-qualified.
bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const
Check if this is or contains a C union that is non-trivial to default-initialize, which is a union th...
A qualifier set is used to build a set of qualifiers.
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
QualType apply(const ASTContext &Context, QualType QT) const
Apply the collected qualifiers to the given type.
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_None
There is no lifetime qualification on this type.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
ObjCLifetime getObjCLifetime() const
Represents a struct/union/class.
bool hasObjectMember() const
field_range fields() const
static RecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, RecordDecl *PrevDecl=nullptr)
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
virtual void completeDefinition()
Note that the definition of this type is now complete.
@ APK_CanNeverPassInRegs
The argument of this type cannot be passed directly in registers.
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
field_iterator field_begin() const
Frontend produces RecoveryExprs on semantic errors that prevent creating other well-formed expression...
void setMemberSpecialization()
Note that this member template is a specialization.
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
redecl_iterator redecls_end() const
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Base for LValueReferenceType and RValueReferenceType.
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
void setNRVOCandidate(const VarDecl *Var)
Set the variable that might be used for the named return value optimization.
Scope - A scope is a transient data structure that is used while parsing the program.
bool isDeclScope(const Decl *D) const
isDeclScope - Return true if this is the scope that the specified decl is declared in.
DeclContext * getEntity() const
Get the entity corresponding to this scope.
bool isCompoundStmtScope() const
Determine whether this scope is a compound statement scope.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
@ TemplateParamScope
This is a scope that corresponds to the template parameters of a C++ template.
@ DeclScope
This is a scope that can contain a declaration.
Mode getAlignMode() const
A class which encapsulates the logic for delaying diagnostics during parsing and other processing.
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
void add(const sema::DelayedDiagnostic &diag)
Adds a delayed diagnostic.
static NameClassification DependentNonType()
static NameClassification VarTemplate(TemplateName Name)
static NameClassification Unknown()
static NameClassification OverloadSet(ExprResult E)
static NameClassification UndeclaredTemplate(TemplateName Name)
static NameClassification FunctionTemplate(TemplateName Name)
static NameClassification NonType(NamedDecl *D)
static NameClassification Concept(TemplateName Name)
static NameClassification UndeclaredNonType()
static NameClassification TypeTemplate(TemplateName Name)
static NameClassification Error()
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
A generic diagnostic builder for errors which may or may not be deferred.
Sema - This implements semantic analysis and AST building for C.
AvailabilityAttr * mergeAvailabilityAttr(NamedDecl *D, const AttributeCommonInfo &CI, IdentifierInfo *Platform, bool Implicit, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable, StringRef Message, bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK, int Priority)
Attribute merging methods. Return true if a new attribute was added.
StmtResult ActOnCXXForRangeIdentifier(Scope *S, SourceLocation IdentLoc, IdentifierInfo *Ident, ParsedAttributes &Attrs)
QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement)
Substitute Replacement for auto in TypeWithAuto.
bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old, Scope *S)
MergeCXXFunctionDecl - Merge two declarations of the same C++ function, once we already know that the...
Attr * getImplicitCodeSegOrSectionAttrForFunction(const FunctionDecl *FD, bool IsDefinition)
Returns an implicit CodeSegAttr if a __declspec(code_seg) is found on a containing class.
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
void CheckTypedefForVariablyModifiedType(Scope *S, TypedefNameDecl *D)
CXXSpecialMember getSpecialMember(const CXXMethodDecl *MD)
void ActOnObjCContainerStartDefinition(ObjCContainerDecl *IDecl)
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Scope * getCurScope() const
Retrieve the parser's current scope.
void MergeTypedefNameDecl(Scope *S, TypedefNameDecl *New, LookupResult &OldDecls)
MergeTypedefNameDecl - We just parsed a typedef 'New' which has the same name and scope as a previous...
CUDAFunctionTarget IdentifyCUDATarget(const FunctionDecl *D, bool IgnoreImplicitHDAttr=false)
Determines whether the given function is a CUDA device/host/kernel/etc.
bool hasStructuralCompatLayout(Decl *D, Decl *Suggested)
Determine if D and Suggested have a structurally compatible layout as described in C11 6....
void RegisterLocallyScopedExternCDecl(NamedDecl *ND, Scope *S)
Register the given locally-scoped extern "C" declaration so that it can be found later for redeclarat...
BTFDeclTagAttr * mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL)
bool isIncompatibleTypedef(TypeDecl *Old, TypedefNameDecl *New)
NamedDecl * ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope)
bool CheckOverridingFunctionAttributes(const CXXMethodDecl *New, const CXXMethodDecl *Old)
void adjustMemberFunctionCC(QualType &T, bool IsStatic, bool IsCtorOrDtor, SourceLocation Loc)
Adjust the calling convention of a method to be the ABI default if it wasn't specified explicitly.
void CheckObjCMethodOverride(ObjCMethodDecl *NewMethod, const ObjCMethodDecl *Overridden)
Check whether the given new method is a valid override of the given overridden method,...
bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S=nullptr, bool AllowInlineNamespace=false) const
isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true if 'D' is in Scope 'S',...
Decl * ActOnIvar(Scope *S, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, tok::ObjCKeywordKind visibility)
ActOnIvar - Each ivar field of an objective-c class is passed into this in order to create an IvarDec...
void DiagnoseUnusedParameters(ArrayRef< ParmVarDecl * > Parameters)
Diagnose any unused parameters in the given sequence of ParmVarDecl pointers.
Decl * ActOnParamDeclarator(Scope *S, Declarator &D)
ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator() to introduce parameters into fun...
void MergeVarDeclExceptionSpecs(VarDecl *New, VarDecl *Old)
Merge the exception specifications of two variable declarations.
LookupNameKind
Describes the kind of name lookup to perform.
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupNestedNameSpecifierName
Look up of a name that precedes the '::' scope resolution operator in C++.
@ LookupLocalFriendName
Look up a friend of a local class.
@ LookupRedeclarationWithLinkage
Look up an ordinary name that is going to be redeclared as a name with linkage.
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
void DiagnoseFunctionSpecifiers(const DeclSpec &DS)
Diagnose function specifiers on a declaration of an identifier that does not identify a function.
void ActOnPopScope(SourceLocation Loc, Scope *S)
Scope actions.
EnforceTCBAttr * mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL)
Decl * ActOnSkippedFunctionBody(Decl *Decl)
QualType deduceVarTypeFromInitializer(VarDecl *VDecl, DeclarationName Name, QualType Type, TypeSourceInfo *TSI, SourceRange Range, bool DirectInit, Expr *Init)
Decl * ActOnTopLevelStmtDecl(Stmt *Statement)
bool SetMemberAccessSpecifier(NamedDecl *MemberDecl, NamedDecl *PrevMemberDecl, AccessSpecifier LexicalAS)
SetMemberAccessSpecifier - Set the access specifier of a member.
@ NTCUC_DefaultInitializedObject
bool MergeFunctionDecl(FunctionDecl *New, NamedDecl *&Old, Scope *S, bool MergeTypeWithOld, bool NewDeclIsDefn)
MergeFunctionDecl - We just parsed a function 'New' from declarator D which has the same name and sco...
void RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind, uint64_t MagicValue, QualType Type, bool LayoutCompatible, bool MustBeNull)
Register a magic integral constant to be used as a type tag.
void LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID)
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
ExprResult BuildIvarRefExpr(Scope *S, SourceLocation Loc, ObjCIvarDecl *IV)
void ActOnTagDefinitionError(Scope *S, Decl *TagDecl)
ActOnTagDefinitionError - Invoked when there was an unrecoverable error parsing the definition of a t...
void CheckCompletedCoroutineBody(FunctionDecl *FD, Stmt *&Body)
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true, bool ConsiderRequiresClauses=true)
TypeVisibilityAttr * mergeTypeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, TypeVisibilityAttr::VisibilityType Vis)
DeclResult LookupIvarInObjCMethod(LookupResult &Lookup, Scope *S, IdentifierInfo *II)
The parser has read a name in, and Sema has detected that we're currently inside an ObjC method.
bool DiagnoseClassNameShadow(DeclContext *DC, DeclarationNameInfo Info)
DiagnoseClassNameShadow - Implement C++ [class.mem]p13: If T is the name of a class,...
void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc, CXXRecordDecl *Record)
MarkBaseAndMemberDestructorsReferenced - Given a record decl, mark all the non-trivial destructors of...
const TranslationUnitKind TUKind
The kind of translation unit we are processing.
void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl, SourceRange BraceRange)
ActOnTagFinishDefinition - Invoked once we have finished parsing the definition of a tag (enumeration...
FunctionEmissionStatus
Status of the function emission on the CUDA/HIP/OpenMP host/device attrs.
llvm::SmallSetVector< const TypedefNameDecl *, 4 > UnusedLocalTypedefNameCandidates
Set containing all typedefs that are likely unused.
PragmaClangSection PragmaClangRodataSection
NamedDecl * ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II, Scope *S)
ImplicitlyDefineFunction - An undeclared identifier was used in a function call, forming a call to an...
std::unique_ptr< CXXFieldCollector > FieldCollector
FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
void AddPragmaAttributes(Scope *S, Decl *D)
Adds the attributes that have been specified using the '#pragma clang attribute push' directives to t...
TemplateDecl * AdjustDeclIfTemplate(Decl *&Decl)
AdjustDeclIfTemplate - If the given decl happens to be a template, reset the parameter D to reference...
void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl=nullptr, ExpressionEvaluationContextRecord::ExpressionKind Type=ExpressionEvaluationContextRecord::EK_Other)
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
llvm::SmallPtrSet< const Decl *, 4 > ParsingInitForAutoVars
ParsingInitForAutoVars - a set of declarations with auto types for which we are currently parsing the...
WebAssemblyImportNameAttr * mergeImportNameAttr(Decl *D, const WebAssemblyImportNameAttr &AL)
void ActOnExitFunctionContext()
bool CheckDependentFunctionTemplateSpecialization(FunctionDecl *FD, const TemplateArgumentListInfo &ExplicitTemplateArgs, LookupResult &Previous)
Perform semantic analysis for the given dependent function template specialization.
ExprResult RebuildExprInCurrentInstantiation(Expr *E)
PoppedFunctionScopePtr PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP=nullptr, const Decl *D=nullptr, QualType BlockType=QualType())
Pop a function (or block or lambda or captured region) scope from the stack.
Preprocessor & getPreprocessor() const
void deduceOpenCLAddressSpace(ValueDecl *decl)
void CheckHLSLEntryPoint(FunctionDecl *FD)
PragmaStack< StringLiteral * > CodeSegStack
void AddRangeBasedOptnone(FunctionDecl *FD)
Only called on function definitions; if there is a pragma in scope with the effect of a range-based o...
bool CheckIfOverriddenFunctionIsMarkedFinal(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckForFunctionMarkedFinal - Checks whether a virtual member function overrides a virtual member fun...
DLLImportAttr * mergeDLLImportAttr(Decl *D, const AttributeCommonInfo &CI)
static NamedDecl * getAsTemplateNameDecl(NamedDecl *D, bool AllowFunctionTemplates=true, bool AllowDependent=true)
Try to interpret the lookup result D as a template-name.
bool CheckForConstantInitializer(Expr *e, QualType t)
type checking declaration initializers (C99 6.7.8)
NamedDecl * HandleDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists)
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=NoFold)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
TemplateParameterList * MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc, SourceLocation DeclLoc, const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId, ArrayRef< TemplateParameterList * > ParamLists, bool IsFriend, bool &IsMemberSpecialization, bool &Invalid, bool SuppressDiagnostic=false)
Match the given template parameter lists to the given scope specifier, returning the template paramet...
void handleTagNumbering(const TagDecl *Tag, Scope *TagScope)
void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl)
AddImplicitlyDeclaredMembersToClass - Adds any implicitly-declared special functions,...
void AddAlignmentAttributesForRecord(RecordDecl *RD)
AddAlignmentAttributesForRecord - Adds any needed alignment attributes to a the record decl,...
ErrorAttr * mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI, StringRef NewUserDiagnostic)
Decl * ActOnConversionDeclarator(CXXConversionDecl *Conversion)
ActOnConversionDeclarator - Called by ActOnDeclarator to complete the declaration of the given C++ co...
void CheckMain(FunctionDecl *FD, const DeclSpec &D)
void AddKnownFunctionAttributes(FunctionDecl *FD)
Adds any function attributes that we know a priori based on the declaration of this function.
void DiagnoseUnusedButSetDecl(const VarDecl *VD, DiagReceiverTy DiagReceiver)
If VD is set but not otherwise used, diagnose, for a parameter or a variable.
FieldDecl * HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, InClassInitStyle InitStyle, AccessSpecifier AS)
HandleField - Analyze a field of a C struct or a C++ data member.
ExprResult ActOnDependentIdExpression(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, bool isAddressOfOperand, const TemplateArgumentListInfo *TemplateArgs)
ActOnDependentIdExpression - Handle a dependent id-expression that was just parsed.
void CheckThreadLocalForLargeAlignment(VarDecl *VD)
void ActOnReenterFunctionContext(Scope *S, Decl *D)
Push the parameters of D, which must be a function, into scope.
FunctionDecl * getCurFunctionDecl(bool AllowLambda=false) const
Returns a pointer to the innermost enclosing function, or nullptr if the current context is not insid...
const AttributedType * getCallingConvAttributedType(QualType T) const
Get the outermost AttributedType node that sets a calling convention.
TypeSpecifierType isTagName(IdentifierInfo &II, Scope *S)
isTagName() - This method is called for error recovery purposes only to determine if the specified na...
bool CheckRedeclarationExported(NamedDecl *New, NamedDecl *Old)
llvm::DenseMap< const EnumDecl *, llvm::APInt > FlagBitsCache
A cache of the flags available in enumerations with the flag_bits attribute.
void CheckConversionDeclarator(Declarator &D, QualType &R, StorageClass &SC)
CheckConversionDeclarator - Called by ActOnDeclarator to check the well-formednes of the conversion f...
VisibilityAttr * mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, VisibilityAttr::VisibilityType Vis)
TemplateNameKind isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool &MemberOfUnknownSpecialization, bool Disambiguation=false)
Decl * ActOnFileScopeAsmDecl(Expr *expr, SourceLocation AsmLoc, SourceLocation RParenLoc)
ParmVarDecl * BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc, QualType T)
Synthesizes a variable for a parameter arising from a typedef.
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
DeclarationNameInfo GetNameForDeclarator(Declarator &D)
GetNameForDeclarator - Determine the full declaration name for the given Declarator.
DiagnosticsEngine & getDiagnostics() const
bool LookupBuiltin(LookupResult &R)
Lookup a builtin function, when name lookup would otherwise fail.
void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec, TypedefNameDecl *NewTD)
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
PragmaStack< bool > StrictGuardStackCheckStack
UnusedFileScopedDeclsType UnusedFileScopedDecls
The set of file scoped decls seen so far that have not been used and must warn if not used.
NamedDecl * LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S, bool ForRedeclaration, SourceLocation Loc)
LazilyCreateBuiltin - The specified Builtin-ID was first used at file scope.
ASTContext & getASTContext() const
void translateTemplateArguments(const ASTTemplateArgsPtr &In, TemplateArgumentListInfo &Out)
Translates template arguments as provided by the parser into template arguments used by semantic anal...
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration.
bool isCurrentClassName(const IdentifierInfo &II, Scope *S, const CXXScopeSpec *SS=nullptr)
isCurrentClassName - Determine whether the identifier II is the name of the class type currently bein...
bool IsRedefinitionInModule(const NamedDecl *New, const NamedDecl *Old) const
bool checkThisInStaticMemberFunctionType(CXXMethodDecl *Method)
Check whether 'this' shows up in the type of a static member function after the (naturally empty) cv-...
void DiagnoseUnguardedAvailabilityViolations(Decl *FD)
Issue any -Wunguarded-availability warnings in FD.
void PopExpressionEvaluationContext()
PragmaStack< StringLiteral * > ConstSegStack
bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S)
isMicrosoftMissingTypename - In Microsoft mode, within class scope, if a CXXScopeSpec's type is equal...
SmallVector< VarDecl *, 4 > ExternalDeclarations
All the external declarations encoutered and used in the TU.
bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R, bool HasTrailingLParen)
void inferGslPointerAttribute(NamedDecl *ND, CXXRecordDecl *UnderlyingRecord)
Add gsl::Pointer attribute to std::container::iterator.
bool checkVarDeclRedefinition(VarDecl *OldDefn, VarDecl *NewDefn)
We've just determined that Old and New both appear to be definitions of the same variable.
bool RequireLiteralType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a literal type.
void ProcessPragmaWeak(Scope *S, Decl *D)
bool shouldIgnoreInHostDeviceCheck(FunctionDecl *Callee)
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
Decl * BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, AccessSpecifier AS, RecordDecl *Record, const PrintingPolicy &Policy)
BuildAnonymousStructOrUnion - Handle the declaration of an anonymous structure or union.
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
bool isAcceptableTagRedeclaration(const TagDecl *Previous, TagTypeKind NewTag, bool isDefinition, SourceLocation NewTagLoc, const IdentifierInfo *Name)
Determine whether a tag with a given kind is acceptable as a redeclaration of the given tag declarati...
void MarkTypoCorrectedFunctionDefinition(const NamedDecl *F)
ExprResult CheckConvertedConstantExpression(Expr *From, QualType T, llvm::APSInt &Value, CCEKind CCE)
@ TPL_TemplateMatch
We are matching the template parameter lists of two templates that might be redeclarations.
EnumDecl * getStdAlignValT() const
LazyDeclPtr StdBadAlloc
The C++ "std::bad_alloc" class, which is defined by the C++ standard library.
bool CheckFunctionTemplateSpecialization(FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous, bool QualifiedFriend=false)
Perform semantic analysis for the given function template specialization.
bool UnifySection(StringRef SectionName, int SectionFlags, NamedDecl *TheDecl)
void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld)
MergeVarDeclTypes - We parsed a variable 'New' which has the same name and scope as a previous declar...
llvm::DenseMap< IdentifierInfo *, AsmLabelAttr * > ExtnameUndeclaredIdentifiers
ExtnameUndeclaredIdentifiers - Identifiers contained in #pragma redefine_extname before declared.
void checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D, SourceLocation IdLoc=SourceLocation())
Check declaration inside target region.
void PushFunctionScope()
Enter a new function scope.
ExprResult ActOnNameClassifiedAsNonType(Scope *S, const CXXScopeSpec &SS, NamedDecl *Found, SourceLocation NameLoc, const Token &NextToken)
Act on the result of classifying a name as a specific non-type declaration.
bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS)
void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl, ObjCIvarDecl **Fields, unsigned nIvars, SourceLocation Loc)
CheckImplementationIvars - This routine checks if the instance variables listed in the implelementati...
void inferGslOwnerPointerAttribute(CXXRecordDecl *Record)
Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
bool CheckEnumUnderlyingType(TypeSourceInfo *TI)
Check that this is a valid underlying type for an enum declaration.
bool FriendConstraintsDependOnEnclosingTemplate(const FunctionDecl *FD)
FPOptions & getCurFPFeatures()
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
sema::LambdaScopeInfo * PushLambdaScope()
@ UPPC_FixedUnderlyingType
The fixed underlying type of an enumeration.
@ UPPC_EnumeratorValue
The enumerator value.
@ UPPC_Initializer
An initializer.
@ UPPC_DeclarationType
The type of an arbitrary declaration.
@ UPPC_DeclarationQualifier
A declaration qualifier.
@ UPPC_DataMemberType
The type of a data member.
@ UPPC_BitFieldWidth
The size of a bit-field.
void checkAllowedCUDAInitializer(VarDecl *VD)
const LangOptions & getLangOpts() const
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
bool RebuildTemplateParamsInCurrentInstantiation(TemplateParameterList *Params)
Rebuild the template parameters now that we know we're in a current instantiation.
void DiagnoseInvalidJumps(Stmt *Body)
SourceLocation CurInitSegLoc
bool currentModuleIsHeaderUnit() const
Is the module scope we are in a C++ Header Unit?
void EnterTemplatedContext(Scope *S, DeclContext *DC)
Enter a template parameter scope, after it's been associated with a particular DeclContext.
bool tryToFixVariablyModifiedVarType(TypeSourceInfo *&TInfo, QualType &T, SourceLocation Loc, unsigned FailedFoldDiagID)
Attempt to fold a variable-sized type to a constant-sized type, returning true if we were successful.
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
NamedDecl * findLocallyScopedExternCDecl(DeclarationName Name)
Look for a locally scoped extern "C" declaration by the given name.
bool CheckRedeclarationModuleOwnership(NamedDecl *New, NamedDecl *Old)
We've determined that New is a redeclaration of Old.
bool TemplateParameterListsAreEqual(const NamedDecl *NewInstFrom, TemplateParameterList *New, const NamedDecl *OldInstFrom, TemplateParameterList *Old, bool Complain, TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc=SourceLocation())
Determine whether the given template parameter lists are equivalent.
bool CheckConstexprFunctionDefinition(const FunctionDecl *FD, CheckConstexprKind Kind)
void ActOnFinishedFunctionDefinitionInOpenMPDeclareVariantScope(Decl *D, SmallVectorImpl< FunctionDecl * > &Bases)
Register D as specialization of all base functions in Bases in the current omp begin/end declare vari...
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
MinSizeAttr * mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI)
NamedDecl * getShadowedDeclaration(const TypedefNameDecl *D, const LookupResult &R)
Return the declaration shadowed by the given typedef D, or null if it doesn't shadow any declaration ...
void checkTypeSupport(QualType Ty, SourceLocation Loc, ValueDecl *D=nullptr)
Check if the type is allowed to be used for the current target.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
void CheckExtraCXXDefaultArguments(Declarator &D)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator,...
void CheckCompleteDecompositionDeclaration(DecompositionDecl *DD)
const LangOptions & LangOpts
TemplateDeductionResult
Describes the result of template argument deduction.
@ TDK_Success
Template argument deduction was successful.
@ TDK_AlreadyDiagnosed
Some error which was already diagnosed.
void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock)
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
bool isReachable(const NamedDecl *D)
Determine whether a declaration is reachable.
void DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl)
DiagnoseTemplateParameterShadow - Produce a diagnostic complaining that the template parameter 'PrevD...
Decl * ActOnStartOfFunctionDef(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists, SkipBodyInfo *SkipBody=nullptr, FnBodyKind BodyKind=FnBodyKind::Other)
ParmVarDecl * CheckParameter(DeclContext *DC, SourceLocation StartLoc, SourceLocation NameLoc, IdentifierInfo *Name, QualType T, TypeSourceInfo *TSInfo, StorageClass SC)
bool ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const
bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, LookupResult &Previous, bool IsMemberSpecialization, bool DeclIsDefn)
Perform semantic checking of a new function declaration.
CXXRecordDecl * getStdBadAlloc() const
AlwaysInlineAttr * mergeAlwaysInlineAttr(Decl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Ident)
FieldDecl * CheckFieldDecl(DeclarationName Name, QualType T, TypeSourceInfo *TInfo, RecordDecl *Record, SourceLocation Loc, bool Mutable, Expr *BitfieldWidth, InClassInitStyle InitStyle, SourceLocation TSSL, AccessSpecifier AS, NamedDecl *PrevDecl, Declarator *D=nullptr)
Build a new FieldDecl and check its well-formedness.
QualType CheckDestructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckDestructorDeclarator - Called by ActOnDeclarator to check the well-formednes of the destructor d...
PragmaClangSection PragmaClangRelroSection
QualType CheckTypenameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo &II, SourceLocation IILoc, TypeSourceInfo **TSI, bool DeducedTSTContext)
void DiagnoseNontrivial(const CXXRecordDecl *Record, CXXSpecialMember CSM)
Diagnose why the specified class does not have a trivial special member of the given kind.
bool DeduceFunctionTypeFromReturnExpr(FunctionDecl *FD, SourceLocation ReturnLoc, Expr *RetExpr, const AutoType *AT)
Deduce the return type for a function from a returned expression, per C++1y [dcl.spec....
void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D)
void CheckCXXDefaultArguments(FunctionDecl *FD)
CheckCXXDefaultArguments - Verify that the default arguments for a function declaration are well-form...
bool checkUnsafeAssigns(SourceLocation Loc, QualType LHS, Expr *RHS)
checkUnsafeAssigns - Check whether +1 expr is being assigned to weak/__unsafe_unretained type.
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
void ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AttrList, const ProcessDeclAttributeOptions &Options=ProcessDeclAttributeOptions())
ProcessDeclAttributeList - Apply all the decl attributes in the specified attribute list to the speci...
void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, bool DefinitionRequired=false)
Note that the vtable for the given class was used at the given location.
WebAssemblyImportModuleAttr * mergeImportModuleAttr(Decl *D, const WebAssemblyImportModuleAttr &AL)
void MaybeAddCUDAConstantAttr(VarDecl *VD)
May add implicit CUDAConstantAttr attribute to VD, depending on VD and current compilation settings.
void AddImplicitMSFunctionNoBuiltinAttr(FunctionDecl *FD)
Only called on function definitions; if there is a pragma in scope with the effect of a range-based n...
PragmaStack< AlignPackInfo > AlignPackStack
bool canDelayFunctionBody(const Declarator &D)
Determine whether we can delay parsing the body of a function or function template until it is used,...
PragmaStack< StringLiteral * > BSSSegStack
bool hasAnyAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true, bool AllowDependent=true, bool AllowNonTemplateFunctions=false)
DeclContext * getCurLexicalContext() const
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, const CXXScopeSpec &SS, QualType T, TagDecl *OwnedTagDecl=nullptr)
Retrieve a version of the type 'T' that is elaborated by Keyword, qualified by the nested-name-specif...
OverloadKind CheckOverload(Scope *S, FunctionDecl *New, const LookupResult &OldDecls, NamedDecl *&OldDecl, bool UseMemberUsingDeclRules)
Determine whether the given New declaration is an overload of the declarations in Old.
bool CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl)
CheckOverloadedOperatorDeclaration - Check whether the declaration of this overloaded operator is wel...
bool hasExplicitCallingConv(QualType T)
NameClassification ClassifyName(Scope *S, CXXScopeSpec &SS, IdentifierInfo *&Name, SourceLocation NameLoc, const Token &NextToken, CorrectionCandidateCallback *CCC=nullptr)
Perform name lookup on the given name, classifying it based on the results of name lookup and the fol...
NonTagKind getNonTagTypeDeclKind(const Decl *D, TagTypeKind TTK)
Given a non-tag type declaration, returns an enum useful for indicating what kind of non-tag type thi...
void ExitDeclaratorContext(Scope *S)
bool isInOpenMPDeclareTargetContext() const
Return true inside OpenMP declare target region.
void DiagnoseShadowingLambdaDecls(const sema::LambdaScopeInfo *LSI)
Diagnose shadowing for variables shadowed in the lambda record LambdaRD when these variables are capt...
bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, bool AllowBuiltinCreation=false, bool EnteringContext=false)
Performs name lookup for a name that was parsed in the source code, and may contain a C++ scope speci...
void CheckConstructor(CXXConstructorDecl *Constructor)
CheckConstructor - Checks a fully-formed constructor for well-formedness, issuing any diagnostics req...
void AddCFAuditedAttribute(Decl *D)
AddCFAuditedAttribute - Check whether we're currently within '#pragma clang arc_cf_code_audited' and,...
void CheckMSVCRTEntryPoint(FunctionDecl *FD)
Decl * ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant, SourceLocation IdLoc, IdentifierInfo *Id, const ParsedAttributesView &Attrs, SourceLocation EqualLoc, Expr *Val)
sema::FunctionScopeInfo * getCurFunction() const
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl * > Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
FunctionDecl * CreateBuiltin(IdentifierInfo *II, QualType Type, unsigned ID, SourceLocation Loc)
Scope * getNonFieldDeclScope(Scope *S)
getNonFieldDeclScope - Retrieves the innermost scope, starting from S, where a non-field would be dec...
void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc)
ActOnPragmaWeakID - Called on well formed #pragma weak ident.
bool CheckNontrivialField(FieldDecl *FD)
HLSLNumThreadsAttr * mergeHLSLNumThreadsAttr(Decl *D, const AttributeCommonInfo &AL, int X, int Y, int Z)
llvm::DenseMap< const VarDecl *, int > RefsMinusAssignments
Increment when we find a reference; decrement when we find an ignored assignment.
void AddPushedVisibilityAttribute(Decl *RD)
AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used, add an appropriate visibility at...
bool checkThisInStaticMemberFunctionAttributes(CXXMethodDecl *Method)
Check whether 'this' shows up in the attributes of the given static member function.
void ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagDecl, SourceLocation FinalLoc, bool IsFinalSpelledSealed, bool IsAbstract, SourceLocation LBraceLoc)
ActOnStartCXXMemberDeclarations - Invoked when we have parsed a C++ record definition's base-specifie...
DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams, AccessSpecifier AS, SourceLocation ModulePrivateLoc, SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists, TemplateParameterList **OuterTemplateParamLists, SkipBodyInfo *SkipBody=nullptr)
ExprResult VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName, QualType FieldTy, bool IsMsStruct, Expr *BitWidth)
VerifyBitField - verifies that a bit field expression is an ICE and has the correct width,...
bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous)
Perform semantic checking on a newly-created variable declaration.
ExprResult DefaultLvalueConversion(Expr *E)
MSInheritanceAttr * mergeMSInheritanceAttr(Decl *D, const AttributeCommonInfo &CI, bool BestCase, MSInheritanceModel Model)
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
bool isVisible(const NamedDecl *D)
Determine whether a declaration is visible to name lookup.
StringLiteral * CurInitSeg
Last section used with #pragma init_seg.
FunctionEmissionStatus getEmissionStatus(const FunctionDecl *Decl, bool Final=false)
Module * getCurrentModule() const
Get the module unit whose scope we are currently within.
bool CheckDeductionGuideDeclarator(Declarator &D, QualType &R, StorageClass &SC)
Check the validity of a declarator that we parsed for a deduction-guide.
bool AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD)
AddOverriddenMethods - See if a method overrides any in the base classes, and if so,...
InternalLinkageAttr * mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL)
void CheckForFunctionRedefinition(FunctionDecl *FD, const FunctionDecl *EffectiveDefinition=nullptr, SkipBodyInfo *SkipBody=nullptr)
void DiagnoseAutoDeductionFailure(VarDecl *VDecl, Expr *Init)
bool ActOnDuplicateDefinition(Decl *Prev, SkipBodyInfo &SkipBody)
Perform ODR-like check for C/ObjC when merging tag types from modules.
void ActOnFinishInlineFunctionDef(FunctionDecl *D)
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
RedeclarationKind
Specifies whether (or how) name lookup is being performed for a redeclaration (vs.
@ NotForRedeclaration
The lookup is a reference to this name that is not for the purpose of redeclaring the name.
@ ForVisibleRedeclaration
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
@ ForExternalRedeclaration
The lookup results will be used for redeclaration of a name with external linkage; non-visible lookup...
void ActOnDocumentableDecl(Decl *D)
Should be called on all declarations that might have attached documentation comments.
void ActOnFinishedFunctionDefinitionInOpenMPAssumeScope(Decl *D)
Act on D, a function definition inside of an omp [begin/end] assumes.
DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name)
Retrieves the declaration name from a parsed unqualified-id.
TypeSourceInfo * RebuildTypeInCurrentInstantiation(TypeSourceInfo *T, SourceLocation Loc, DeclarationName Name)
Rebuilds a type within the context of the current instantiation.
void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
void maybeAddCUDAHostDeviceAttrs(FunctionDecl *FD, const LookupResult &Previous)
May add implicit CUDAHostAttr and CUDADeviceAttr attributes to FD, depending on FD and the current co...
bool CheckFunctionConstraints(const FunctionDecl *FD, ConstraintSatisfaction &Satisfaction, SourceLocation UsageLoc=SourceLocation(), bool ForOverloadResolution=false)
Check whether the given function decl's trailing requires clause is satisfied, if any.
bool CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl)
CheckLiteralOperatorDeclaration - Check whether the declaration of this literal operator function is ...
void CheckShadowingDeclModification(Expr *E, SourceLocation Loc)
Warn if 'E', which is an expression that is about to be modified, refers to a shadowing declaration.
SkipBodyInfo shouldSkipAnonEnumBody(Scope *S, IdentifierInfo *II, SourceLocation IILoc)
Determine whether the body of an anonymous enumeration should be skipped.
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
void notePreviousDefinition(const NamedDecl *Old, SourceLocation New)
ObjCContainerDecl * getObjCDeclContext() const
DLLExportAttr * mergeDLLExportAttr(Decl *D, const AttributeCommonInfo &CI)
bool isInOpenMPDeclareVariantScope() const
Can we exit an OpenMP declare variant scope at the moment.
DeclContext * OriginalLexicalContext
Generally null except when we temporarily switch decl contexts, like in.
bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a visible definition.
CodeSegAttr * mergeCodeSegAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Name)
SectionAttr * mergeSectionAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Name)
bool canSkipFunctionBody(Decl *D)
Determine whether we can skip parsing the body of a function definition, assuming we don't care about...
bool canFullyTypeCheckRedeclaration(ValueDecl *NewD, ValueDecl *OldD, QualType NewT, QualType OldT)
Determines if we can perform a correct type check for D as a redeclaration of PrevDecl.
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
@ NTK_TemplateTemplateArgument
void ActOnObjCContainerFinishDefinition()
SourceManager & getSourceManager() const
NamedDecl * ActOnDecompositionDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists)
Decl * ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, MultiTemplateParamsArg TemplateParams)
Handle a friend type declaration.
bool MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old, Scope *S, bool MergeTypeWithOld)
Completes the merge of two function declarations that are known to be compatible.
void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange, Decl *EnumDecl, ArrayRef< Decl * > Elements, Scope *S, const ParsedAttributesView &Attr)
void EnterDeclaratorContext(Scope *S, DeclContext *DC)
EnterDeclaratorContext - Used when we must lookup names in the context of a declarator's nested name ...
bool areMultiversionVariantFunctionsCompatible(const FunctionDecl *OldFD, const FunctionDecl *NewFD, const PartialDiagnostic &NoProtoDiagID, const PartialDiagnosticAt &NoteCausedDiagIDAt, const PartialDiagnosticAt &NoSupportDiagIDAt, const PartialDiagnosticAt &DiffDiagIDAt, bool TemplatesSupported, bool ConstexprSupported, bool CLinkageMayDiffer)
Checks if the variant/multiversion functions are compatible.
QualType DeduceTemplateSpecializationFromInitializer(TypeSourceInfo *TInfo, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Init, ParenListExpr *PL=nullptr)
RedeclarationKind forRedeclarationInCurContext() const
void ActOnTagStartDefinition(Scope *S, Decl *TagDecl)
ActOnTagStartDefinition - Invoked when we have entered the scope of a tag's definition (e....
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
PragmaClangSection PragmaClangTextSection
PragmaClangSection PragmaClangDataSection
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
Decl * ActOnFinishFunctionBody(Decl *Decl, Stmt *Body)
void ActOnStartOfFunctionDefinitionInOpenMPDeclareVariantScope(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists, SmallVectorImpl< FunctionDecl * > &Bases)
The declarator D defines a function in the scope S which is nested in an omp begin/end declare varian...
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, bool AllowExplicitConversion=false, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, ConversionSequenceList EarlyConversions=std::nullopt, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
void ActOnInitializerError(Decl *Dcl)
ActOnInitializerError - Given that there was an error parsing an initializer for the given declaratio...
void FilterAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true, bool AllowDependent=true)
void * SkippedDefinitionContext
ExprResult ActOnNameClassifiedAsUndeclaredNonType(IdentifierInfo *Name, SourceLocation NameLoc)
Act on the result of classifying a name as an undeclared (ADL-only) non-type declaration.
bool IsAtLeastAsConstrained(NamedDecl *D1, MutableArrayRef< const Expr * > AC1, NamedDecl *D2, MutableArrayRef< const Expr * > AC2, bool &Result)
Check whether the given declaration's associated constraints are at least as constrained than another...
void ActOnPragmaRedefineExtname(IdentifierInfo *WeakName, IdentifierInfo *AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc)
ActOnPragmaRedefineExtname - Called on well formed #pragma redefine_extname oldname newname.
bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams)
Check whether a template can be declared within this scope.
void AddMsStructLayoutForRecord(RecordDecl *RD)
AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
MaybeODRUseExprSet MaybeODRUseExprs
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
bool CheckParmsForFunctionDef(ArrayRef< ParmVarDecl * > Parameters, bool CheckParameterNames)
Helpers for dealing with blocks and functions.
void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl, const LookupResult &R)
Diagnose variable or built-in function shadowing.
void AdjustDestructorExceptionSpec(CXXDestructorDecl *Destructor)
Build an exception spec for destructors that don't have one.
bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
Perform semantic analysis for the given non-template member specialization.
TypeResult ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS, const IdentifierInfo &II, SourceLocation IdLoc, ImplicitTypenameContext IsImplicitTypename=ImplicitTypenameContext::No)
Called when the parser has parsed a C++ typename specifier, e.g., "typename T::type".
void ActOnObjCReenterContainerContext(ObjCContainerDecl *ObjCCtx)
OptimizeNoneAttr * mergeOptimizeNoneAttr(Decl *D, const AttributeCommonInfo &CI)
bool CheckImmediateEscalatingFunctionDefinition(FunctionDecl *FD, const sema::FunctionScopeInfo *FSI)
ObjCInterfaceDecl * getObjCInterfaceDecl(IdentifierInfo *&Id, SourceLocation IdLoc, bool TypoCorrection=false)
Look for an Objective-C class in the translation unit.
void InstantiateDefaultCtorDefaultArgs(CXXConstructorDecl *Ctor)
In the MS ABI, we need to instantiate default arguments of dllexported default constructors along wit...
void CheckCompleteVariableDeclaration(VarDecl *VD)
DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, ArrayRef< Decl * > Group)
void setFunctionHasBranchProtectedScope()
void MergeVarDecl(VarDecl *New, LookupResult &Previous)
MergeVarDecl - We just parsed a variable 'New' which has the same name and scope as a previous declar...
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
DeclResult ActOnVarTemplateSpecialization(Scope *S, Declarator &D, TypeSourceInfo *DI, SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams, StorageClass SC, bool IsPartialSpecialization)
ParsedType ActOnMSVCUnknownTypeName(const IdentifierInfo &II, SourceLocation NameLoc, bool IsTemplateTypeArg)
Attempt to behave like MSVC in situations where lookup of an unqualified type name has failed in a de...
EnforceTCBLeafAttr * mergeEnforceTCBLeafAttr(Decl *D, const EnforceTCBLeafAttr &AL)
@ CCEK_Enumerator
Enumerator value with fixed underlying type.
void ActOnLastBitfield(SourceLocation DeclStart, SmallVectorImpl< Decl * > &AllIvarDecls)
ActOnLastBitfield - This routine handles synthesized bitfields rules for class and class extensions.
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AMK_Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
void MarkUnusedFileScopedDecl(const DeclaratorDecl *D)
If it's a file scoped decl that must warn if not used, keep track of it.
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=nullptr, bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, bool IsClassTemplateDeductionContext=true, ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type.
EnumConstantDecl * CheckEnumConstant(EnumDecl *Enum, EnumConstantDecl *LastEnumConst, SourceLocation IdLoc, IdentifierInfo *Id, Expr *val)
@ Ovl_NonFunction
This is not an overload because the lookup results contain a non-function.
@ Ovl_Overload
This is a legitimate overload: the existing declarations are functions or function templates with dif...
@ Ovl_Match
This is not an overload because the signature exactly matches an existing declaration.
SmallVector< ExprWithCleanups::CleanupObject, 8 > ExprCleanupObjects
ExprCleanupObjects - This is the stack of objects requiring cleanup that are created by the current f...
void DiagnoseUnusedNestedTypedefs(const RecordDecl *D)
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
bool hasUncompilableErrorOccurred() const
Whether uncompilable error has occurred.
bool ShouldDeleteSpecialMember(CXXMethodDecl *MD, CXXSpecialMember CSM, InheritedConstructorInfo *ICI=nullptr, bool Diagnose=false)
Determine if a special member function should have a deleted definition when it is defaulted.
@ FirstDecl
Parsing the first decl in a TU.
void AddKnownFunctionAttributesForReplaceableGlobalAllocationFunction(FunctionDecl *FD)
If this function is a C++ replaceable global allocation function (C++2a [basic.stc....
bool inferObjCARCLifetime(ValueDecl *decl)
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
void ActOnOpenMPDeclareTargetInitializer(Decl *D)
Adds OMPDeclareTargetDeclAttr to referenced variables in declare target directive.
FormatAttr * mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Format, int FormatIdx, int FirstArg)
AvailabilityMergeKind
Describes the kind of merge to perform for availability attributes (including "deprecated",...
@ AMK_None
Don't merge availability attributes at all.
@ AMK_Override
Merge availability attributes for an override, which requires an exact match or a weakening of constr...
@ AMK_ProtocolImplementation
Merge availability attributes for an implementation of a protocol requirement.
@ AMK_OptionalProtocolImplementation
Merge availability attributes for an implementation of an optional protocol requirement.
@ AMK_Redeclaration
Merge availability attributes for a redeclaration, which requires an exact match.
void ActOnDocumentableDecls(ArrayRef< Decl * > Group)
void CheckStaticLocalForDllExport(VarDecl *VD)
Check if VD needs to be dllexport/dllimport due to being in a dllexport/import function.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
DeclResult ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, AccessSpecifier AS, SourceLocation ModulePrivateLoc, MultiTemplateParamsArg TemplateParameterLists, bool &OwnedDecl, bool &IsDependent, SourceLocation ScopedEnumKWLoc, bool ScopedEnumUsesClassTag, TypeResult UnderlyingType, bool IsTypeSpecifier, bool IsTemplateParamOrArg, OffsetOfKind OOK, SkipBodyInfo *SkipBody=nullptr)
This is invoked when we see 'struct foo' or 'struct {'.
Decl * ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS, const ParsedAttributesView &DeclAttrs, RecordDecl *&AnonRecord)
ParsedFreeStandingDeclSpec - This method is invoked when a declspec with no declarator (e....
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, SourceLocation LocAfterDecls)
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
void ActOnTagFinishSkippedDefinition(SkippedDefinitionContext Context)
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
ExprResult forceUnknownAnyToType(Expr *E, QualType ToType)
Force an expression with unknown-type to an expression of the given type.
void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, ArrayRef< Decl * > Fields, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
void ModifyFnAttributesMSPragmaOptimize(FunctionDecl *FD)
Only called on function definitions; if there is a MSVC #pragma optimize in scope,...
bool shouldLinkDependentDeclWithPrevious(Decl *D, Decl *OldDecl)
Checks if the new declaration declared in dependent context must be put in the same redeclaration cha...
TentativeDefinitionsType TentativeDefinitions
All the tentative definitions encountered in the TU.
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
void DiscardCleanupsInEvaluationContext()
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New)
void makeMergedDefinitionVisible(NamedDecl *ND)
Make a merged definition of an existing hidden definition ND visible at the specified location.
UuidAttr * mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI, StringRef UuidAsWritten, MSGuidDecl *GuidDecl)
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
SourceManager & SourceMgr
bool CheckDestructor(CXXDestructorDecl *Destructor)
CheckDestructor - Checks a fully-formed destructor definition for well-formedness,...
void checkRetainCycles(ObjCMessageExpr *msg)
checkRetainCycles - Check whether an Objective-C message send might create an obvious retain cycle.
Decl * BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS, RecordDecl *Record)
BuildMicrosoftCAnonymousStruct - Handle the declaration of an Microsoft C anonymous structure.
DiagnosticsEngine & Diags
OpenCLOptions & getOpenCLOptions()
NamespaceDecl * getStdNamespace() const
NamedDecl * ActOnTypedefDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous)
PragmaStack< StringLiteral * > DataSegStack
void deduceClosureReturnType(sema::CapturingScopeInfo &CSI)
Deduce a block or lambda's return type based on the return statements present in the body.
static bool adjustContextForLocalExternDecl(DeclContext *&DC)
Adjust the DeclContext for a function or variable that might be a function-local external declaration...
void diagnoseMissingTemplateArguments(TemplateName Name, SourceLocation Loc)
void CheckFunctionOrTemplateParamDeclarator(Scope *S, Declarator &D)
Common checks for a parameter-declaration that should apply to both function parameters and non-type ...
@ TPC_FriendFunctionTemplate
@ TPC_ClassTemplateMember
@ TPC_FriendFunctionTemplateDefinition
NamedDecl * ActOnTypedefNameDecl(Scope *S, DeclContext *DC, TypedefNameDecl *D, LookupResult &Previous, bool &Redeclaration)
ActOnTypedefNameDecl - Perform semantic checking for a declaration which declares a typedef-name,...
void ActOnFinishDelayedAttribute(Scope *S, Decl *D, ParsedAttributes &Attrs)
ActOnFinishDelayedAttribute - Invoked when we have finished parsing an attribute for which parsing is...
void DiagnoseUnusedDecl(const NamedDecl *ND)
void DiagnoseDuplicateIvars(ObjCInterfaceDecl *ID, ObjCInterfaceDecl *SID)
DiagnoseDuplicateIvars - Check for duplicate ivars in the entire class at the start of @implementatio...
llvm::MapVector< NamedDecl *, SourceLocation > UndefinedButUsed
UndefinedInternals - all the used, undefined objects which require a definition in this translation u...
QualType CheckConstructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckConstructorDeclarator - Called by ActOnDeclarator to check the well-formedness of the constructo...
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in it, apply them to D.
QualType SubstAutoTypeDependent(QualType TypeWithAuto)
void FilterLookupForScope(LookupResult &R, DeclContext *Ctx, Scope *S, bool ConsiderLinkage, bool AllowInlineNamespace)
Filters out lookup results that don't fall within the given scope as determined by isDeclInScope.
void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, const WeakInfo &W)
DeclApplyPragmaWeak - A declaration (maybe definition) needs #pragma weak applied to it,...
void ActOnUninitializedDecl(Decl *dcl)
void checkNonTrivialCUnionInInitializer(const Expr *Init, SourceLocation Loc)
Emit diagnostics if the initializer or any of its explicit or implicitly-generated subexpressions req...
static Scope * getScopeForDeclContext(Scope *S, DeclContext *DC)
Finds the scope corresponding to the given decl context, if it happens to be an enclosing scope.
TypedefDecl * ParseTypedefDecl(Scope *S, Declarator &D, QualType T, TypeSourceInfo *TInfo)
Subroutines of ActOnDeclarator().
sema::LambdaScopeInfo * getEnclosingLambda() const
Get the innermost lambda enclosing the current location, if any.
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
HLSLShaderAttr * mergeHLSLShaderAttr(Decl *D, const AttributeCommonInfo &AL, HLSLShaderAttr::ShaderType ShaderType)
bool CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionExceptionSpec - Checks whether the exception spec is a subset of base spec.
Decl * ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth)
ActOnField - Each field of a C struct/union is passed into this in order to create a FieldDecl object...
bool RequireCompleteSizedType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &... Args)
void mergeObjCMethodDecls(ObjCMethodDecl *New, ObjCMethodDecl *Old)
bool CheckTemplateParameterList(TemplateParameterList *NewParams, TemplateParameterList *OldParams, TemplateParamListContext TPC, SkipBodyInfo *SkipBody=nullptr)
Checks the validity of a template parameter list, possibly considering the template parameter list fr...
void ActOnCXXForRangeDecl(Decl *D)
bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionReturnType - Checks whether the return types are covariant,...
bool diagnoseQualifiedDeclaration(CXXScopeSpec &SS, DeclContext *DC, DeclarationName Name, SourceLocation Loc, bool IsTemplateId)
Diagnose a declaration whose declarator-id has the given nested-name-specifier.
std::tuple< MangleNumberingContext *, Decl * > getCurrentMangleNumberContext(const DeclContext *DC)
Compute the mangling number context for a lambda expression or block literal.
llvm::MapVector< IdentifierInfo *, llvm::SetVector< WeakInfo, llvm::SmallVector< WeakInfo, 1u >, llvm::SmallDenseSet< WeakInfo, 2u, WeakInfo::DenseMapInfoByAliasOnly > > > WeakUndeclaredIdentifiers
WeakUndeclaredIdentifiers - Identifiers contained in #pragma weak before declared.
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID, const FunctionDecl *FD=nullptr)
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
PragmaClangSection PragmaClangBSSSection
Decl * ActOnDeclarator(Scope *S, Declarator &D)
TypeSourceInfo * GetTypeForDeclarator(Declarator &D, Scope *S)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
void CheckAlignasUnderalignment(Decl *D)
bool CheckRedeclarationInModule(NamedDecl *New, NamedDecl *Old)
LazyDeclPtr StdAlignValT
The C++ "std::align_val_t" enum class, which is defined by the C++ standard library.
ExprResult ActOnNameClassifiedAsDependentNonType(const CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, bool IsAddressOfOperand)
Act on the result of classifying a name as an undeclared member of a dependent base class.
SwiftNameAttr * mergeSwiftNameAttr(Decl *D, const SwiftNameAttr &SNA, StringRef Name)
void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc)
void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc)
ActOnPragmaWeakAlias - Called on well formed #pragma weak ident = ident.
llvm::function_ref< void(SourceLocation Loc, PartialDiagnostic PD)> DiagReceiverTy
@ Diagnose
Diagnose issues that are non-constant or that are extensions.
void CheckVariableDeclarationType(VarDecl *NewVD)
unsigned getTemplateDepth(Scope *S) const
Determine the number of levels of enclosing template parameters.
CXXSpecialMember
Kinds of C++ special members.
SkippedDefinitionContext ActOnTagStartSkippedDefinition(Scope *S, Decl *TD)
Invoked when we enter a tag definition that we're skipping.
bool DeduceVariableDeclarationType(VarDecl *VDecl, bool DirectInit, Expr *Init)
std::string getCudaConfigureFuncName() const
Returns the name of the launch configuration function.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
llvm::SmallPtrSet< const NamedDecl *, 4 > TypoCorrectedFunctionDefinitions
The function definitions which were renamed as part of typo-correction to match their respective decl...
void AddSectionMSAllocText(FunctionDecl *FD)
Only called on function definitions; if there is a #pragma alloc_text that decides which code section...
void computeNRVO(Stmt *Body, sema::FunctionScopeInfo *Scope)
Given the set of return statements within a function body, compute the variables that are subject to ...
void checkNonTrivialCUnion(QualType QT, SourceLocation Loc, NonTrivialCUnionContext UseContext, unsigned NonTrivialKind)
Emit diagnostics if a non-trivial C union type or a struct that contains a non-trivial C union is use...
IdentifierResolver IdResolver
bool isSimpleTypeSpecifier(tok::TokenKind Kind) const
Determine whether the token kind starts a simple-type-specifier.
TemplateDeductionResult DeduceAutoType(TypeLoc AutoTypeLoc, Expr *Initializer, QualType &Result, sema::TemplateDeductionInfo &Info, bool DependentDeduction=false, bool IgnoreConstraints=false, TemplateSpecCandidateSet *FailedTSC=nullptr)
Deduce the type for an auto type-specifier (C++11 [dcl.spec.auto]p6)
ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, UnresolvedLookupExpr *AsULE=nullptr)
Builds an expression which might be an implicit member expression.
bool IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val, bool AllowMask) const
IsValueInFlagEnum - Determine if a value is allowed as part of a flag enum.
void DiagnoseUnknownTypeName(IdentifierInfo *&II, SourceLocation IILoc, Scope *S, CXXScopeSpec *SS, ParsedType &SuggestedType, bool IsTemplateName=false)
void DiagnoseSizeOfParametersAndReturnValue(ArrayRef< ParmVarDecl * > Parameters, QualType ReturnTy, NamedDecl *D)
Diagnose whether the size of parameters or return value of a function or obj-c method definition is p...
void CheckDeductionGuideTemplate(FunctionTemplateDecl *TD)
llvm::SmallVector< std::pair< SourceLocation, const BlockDecl * >, 1 > ImplicitlyRetainedSelfLocs
List of SourceLocations where 'self' is implicitly retained inside a block.
bool checkMSInheritanceAttrOnDefinition(CXXRecordDecl *RD, SourceRange Range, bool BestCase, MSInheritanceModel SemanticSpelling)
TemplateNameKindForDiagnostics
Describes the detailed kind of a template name. Used in diagnostics.
void checkCUDATargetOverload(FunctionDecl *NewFD, const LookupResult &Previous)
Check whether NewFD is a valid overload for CUDA.
void warnOnReservedIdentifier(const NamedDecl *D)
bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped, QualType EnumUnderlyingTy, bool IsFixed, const EnumDecl *Prev)
Check whether this is a valid redeclaration of a previous enumeration.
void ActOnObjCTemporaryExitContainerContext(ObjCContainerDecl *ObjCCtx)
Invoked when we must temporarily exit the objective-c container scope for parsing/looking-up C constr...
NamedDecl * ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope, ArrayRef< BindingDecl * > Bindings=std::nullopt)
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
ExprResult ActOnNameClassifiedAsOverloadSet(Scope *S, Expr *OverloadSet)
Act on the result of classifying a name as an overload set.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
This class handles loading and caching of source files into memory.
bool isInMainFile(SourceLocation Loc) const
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID.
SourceLocation getIncludeLoc(FileID FID) const
Returns the include location if FID is a #include'd file otherwise it returns an invalid location.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
const FileEntry * getFileEntryForID(FileID FID) const
Returns the FileEntry record for the provided FileID.
StringRef getFilename(SourceLocation SpellingLoc) const
Return the filename of the file containing a SourceLocation.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
Stmt - This represents one statement.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
StringLiteral - This represents a string literal expression, e.g.
SourceLocation getStrTokenLoc(unsigned TokNum) const
Get one of the string literal token.
StringRef getString() const
Represents the declaration of a struct/union/class/enum.
static TagDecl * castFromDeclContext(const DeclContext *DC)
bool isBeingDefined() const
Return true if this decl is currently being defined.
TagDecl * getDefinition() const
Returns the TagDecl that actually defines this struct/union/class/enum.
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
SourceLocation getInnerLocStart() const
Return SourceLocation representing start of source range ignoring outer template declarations.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
void startDefinition()
Starts the definition of this tag declaration.
void setTypedefNameForAnonDecl(TypedefNameDecl *TDD)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type?
TagKind getTagKind() const
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
bool canKeyFunctionBeInline() const
Can an out-of-line inline function serve as a key function?
Exposes information about the current target.
TargetOptions & getTargetOpts() const
Retrieve the target options.
virtual bool validateCpuIs(StringRef Name) const
unsigned getShortWidth() const
Return the size of 'signed short' and 'unsigned short' for this target, in bits.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
unsigned getIntWidth() const
getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for this target,...
virtual bool allowDebugInfoForExternalRef() const
Whether target allows debuginfo types for decl only variables/functions.
unsigned getLongLongWidth() const
getLongLongWidth/Align - Return the size of 'signed long long' and 'unsigned long long' for this targ...
bool isTLSSupported() const
Whether the target supports thread-local storage.
unsigned getMaxTLSAlign() const
Return the maximum alignment (in bits) of a TLS variable.
virtual bool validateCpuSupports(StringRef Name) const
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
virtual bool isValidFeatureName(StringRef Feature) const
Determine whether this TargetInfo supports the given feature.
unsigned getCharWidth() const
virtual ParsedTargetAttr parseTargetAttr(StringRef Str) const
unsigned getLongWidth() const
getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' for this target,...
bool supportsMultiVersioning() const
Identify whether this target supports multiversioning of functions, which requires support for cpu_su...
virtual bool shouldDLLImportComdatSymbols() const
Does this target aim for semantic compatibility with Microsoft C++ code using dllimport/export attrib...
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
virtual bool isValidGCCRegisterName(StringRef Name) const
Returns whether the passed in string is a valid register name according to GCC.
std::string HLSLEntry
The entry point name for HLSL shader being compiled as specified by -E.
A convenient class for passing around template argument information.
void setLAngleLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known.
Stores a list of template parameters for a TemplateDecl and its derived classes.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation getRAngleLoc() const
SourceLocation getTemplateLoc() const
Token - This structure provides full information about a lexed token.
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {....
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
bool isNot(tok::TokenKind K) const
static TopLevelStmtDecl * Create(ASTContext &C, Stmt *Statement)
Represents a declaration of a type.
void setTypeForDecl(const Type *TD)
const Type * getTypeForDecl() const
TypeSpecTypeLoc pushTypeSpec(QualType T)
Pushes space for a typespec TypeLoc.
Base wrapper for a particular "section" of type source info.
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
TypeLoc IgnoreParens() const
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
void initializeFullCopy(TypeLoc Other)
Initializes this by copying its information from another TypeLoc of the same type.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
SourceLocation getEndLoc() const
Get the end source location.
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
SourceLocation getBeginLoc() const
Get the begin source location.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
void setNameLoc(SourceLocation Loc)
The base class of the type hierarchy.
bool isStructureType() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isDependentSizedArrayType() const
bool isBlockPointerType() const
bool isBooleanType() const
bool isFunctionReferenceType() const
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
bool hasAttr(attr::Kind AK) const
Determine whether this type had the specified attribute applied to it (looking through top-level type...
const Type * getPointeeOrArrayElementType() const
If this is a pointer type, return the pointee type.
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
bool isLiteralType(const ASTContext &Ctx) const
Return true if this is a literal type (C++11 [basic.types]p10)
bool isIncompleteArrayType() const
const ArrayType * castAsArrayTypeUnsafe() const
A variant of castAs<> for array type which silently discards qualifiers from the outermost type.
bool isConstantArrayType() const
bool canDecayToPointerType() const
Determines whether this type can decay to a pointer type.
bool isFunctionPointerType() const
bool isPointerType() const
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isScalarType() const
bool isVariableArrayType() const
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type.
bool isOpenCLSpecificType() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type.
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
const RecordType * getAsStructureType() const
bool isWebAssemblyTableType() const
Returns true if this is a WebAssembly table type: either an array of reference types,...
bool containsErrors() const
Whether this type is an error type.
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
bool isAtomicType() const
bool isFunctionProtoType() const
bool isObjCIdType() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
bool isObjCObjectType() const
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
const T * getAsAdjusted() const
Member-template getAsAdjusted<specific type>.
bool isFunctionType() const
bool isObjCObjectPointerType() const
bool isMemberFunctionPointerType() const
bool isFloatingType() const
bool isAnyPointerType() const
bool hasAutoForTrailingReturnType() const
Determine whether this type was written with a leading 'auto' corresponding to a trailing return type...
const T * getAs() const
Member-template getAs<specific type>'.
const Type * getUnqualifiedDesugaredType() const
Return the specified type with any "sugar" removed from the type, removing any typedefs,...
bool isNullPtrType() const
bool isRecordType() const
std::optional< NullabilityKind > getNullability() const
Determine the nullability of the given type.
bool isFunctionNoProtoType() const
bool isReserveIDT() const
TagDecl * getAsTagDecl() const
Retrieves the TagDecl that this type refers to, either because the type is a TagType or because it is...
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
Represents the declaration of a typedef-name via the 'typedef' type specifier.
static TypedefDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo)
Base class for declarations which introduce a typedef-name.
TypeSourceInfo * getTypeSourceInfo() const
void setModedTypeSourceInfo(TypeSourceInfo *unmodedTSI, QualType modedTy)
QualType getUnderlyingType() const
void setTypeSourceInfo(TypeSourceInfo *newType)
TagDecl * getAnonDeclWithTypedefName(bool AnyRedecl=false) const
Retrieves the tag declaration for which this is the typedef name for linkage purposes,...
TypedefNameDecl * getDecl() const
Simple class containing the result of Sema::CorrectTypo.
IdentifierInfo * getCorrectionAsIdentifierInfo() const
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
SmallVectorImpl< NamedDecl * >::const_iterator const_decl_iterator
DeclarationName getCorrection() const
Gets the DeclarationName of the typo correction.
unsigned getEditDistance(bool Normalized=true) const
Gets the "edit distance" of the typo correction from the typo.
NestedNameSpecifier * getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
SmallVectorImpl< NamedDecl * >::iterator decl_iterator
void setCorrectionDecl(NamedDecl *CDecl)
Clears the list of NamedDecls before adding the new one.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Expr * getSubExpr() const
static bool isIncrementDecrementOp(Opcode Op)
Represents a C++ unqualified-id that has been parsed.
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
The iterator over UnresolvedSets.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
BaseUsingDecl * getIntroducer() const
Gets the (written or instantiated) using declaration that introduced this declaration.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void setType(QualType newType)
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
Represents a variable declaration or definition.
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
void setCXXForRangeDecl(bool FRD)
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
TLSKind getTLSKind() const
void setInitStyle(InitializationStyle Style)
DefinitionKind isThisDeclarationADefinition(ASTContext &) const
Check whether this declaration is a definition.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a static data member.
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
@ ListInit
Direct list-initialization (C++11)
@ ParenListInit
Parenthesized list-initialization (C++20)
@ CallInit
Call-style initialization (C++98)
void setStorageClass(StorageClass SC)
void setPreviousDeclInSameBlockScope(bool Same)
bool isStaticDataMember() const
Determines whether this is a static data member.
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
VarDecl * getDefinition(ASTContext &)
Get the real (not just tentative) definition for this declaration.
bool mightBeUsableInConstantExpressions(const ASTContext &C) const
Determine whether this variable's value might be usable in a constant expression, according to the re...
void setInlineSpecified()
bool isStaticLocal() const
Returns true if a variable with function scope is a static local variable.
bool isFileVarDecl() const
Returns true for file scoped variable declaration.
void setTSCSpec(ThreadStorageClassSpecifier TSC)
bool checkForConstantInitialization(SmallVectorImpl< PartialDiagnosticAt > &Notes) const
Evaluate the initializer of this variable to determine whether it's a constant initializer.
bool isInline() const
Whether this variable is (C++1z) inline.
ThreadStorageClassSpecifier getTSCSpec() const
const Expr * getInit() const
bool hasExternalStorage() const
Returns true if a variable has extern or private_extern storage.
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
VarDecl * getInitializingDeclaration()
Get the initializing declaration of this variable, if any.
void setConstexpr(bool IC)
@ TLS_Static
TLS with a known-constant initializer.
@ TLS_Dynamic
TLS with a dynamic initializer.
VarDecl * getActingDefinition()
Get the tentative definition that acts as the real definition in a TU.
@ TentativeDefinition
This declaration is a tentative definition.
@ DeclarationOnly
This declaration is only a declaration.
@ Definition
This declaration is definitely a definition.
void setDescribedVarTemplate(VarTemplateDecl *Template)
bool isExternC() const
Determines whether this variable is a variable with external, C linkage.
bool isLocalVarDecl() const
Returns true for local variable declarations other than parameters.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
void setImplicitlyInline()
bool isThisDeclarationADemotedDefinition() const
If this definition should pretend to be a declaration.
bool isPreviousDeclInSameBlockScope() const
Whether this local extern variable declaration's previous declaration was declared in the same block ...
bool hasDependentAlignment() const
Determines if this variable's alignment is dependent.
bool isLocalVarDeclOrParm() const
Similar to isLocalVarDecl but also includes parameters.
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
void demoteThisDefinitionToDeclaration()
This is a definition which should be demoted to a declaration.
bool isParameterPack() const
Determine whether this variable is actually a function parameter pack or init-capture pack.
Declaration of a variable template.
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
VarTemplateDecl * getInstantiatedFromMemberTemplate() const
static VarTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, VarDecl *Decl)
Create a variable template node.
Represents a C array with a specified size that is not an integer-constant-expression.
Expr * getSizeExpr() const
Captures information about a #pragma weak directive.
void disableCheckFallThrough()
Policy getDefaultPolicy()
ValueDecl * getVariable() const
bool isVariableCapture() const
SourceLocation getLocation() const
Retrieve the location at which this variable was captured.
void addVLATypeCapture(SourceLocation Loc, const VariableArrayType *VLAType, QualType CaptureType)
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
SmallVector< Capture, 4 > Captures
Captures - The captures.
ImplicitCaptureStyle ImpCaptureStyle
void addThisCapture(bool isNested, SourceLocation Loc, QualType CaptureType, bool ByCopy)
void addCapture(ValueDecl *Var, bool isBlock, bool isByref, bool isNested, SourceLocation Loc, SourceLocation EllipsisLoc, QualType CaptureType, bool Invalid)
static DelayedDiagnostic makeForbiddenType(SourceLocation loc, unsigned diagnostic, QualType type, unsigned argument)
Retains information about a function, method, or block that is currently being parsed.
bool UsesFPIntrin
Whether this function uses constrained floating point intrinsics.
void addByrefBlockVar(VarDecl *VD)
bool NeedsScopeChecking() const
bool ObjCShouldCallSuper
A flag that is set when parsing a method that must call super's implementation, such as -dealloc,...
bool ObjCWarnForNoInitDelegation
This starts true for a secondary initializer method and will be set to false if there is an invocatio...
bool HasPotentialAvailabilityViolations
Whether we make reference to a declaration that could be unavailable.
bool ObjCWarnForNoDesignatedInitChain
This starts true for a method marked as designated initializer and will be set to false if there is a...
SourceRange IntroducerRange
Source range covering the lambda introducer [...].
llvm::SmallVector< ShadowedOuterDecl, 4 > ShadowingDecls
CXXRecordDecl * Lambda
The class that describes the lambda.
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
bool Mutable
Whether this is a mutable lambda.
Provides information about an attempted template argument deduction, whose success or failure was des...
Defines the clang::TargetInfo interface.
bool evaluateRequiredTargetFeatures(llvm::StringRef RequiredFatures, const llvm::StringMap< bool > &TargetFetureMap)
Returns true if the required target features of a builtin function are enabled.
const internal::VariadicAllOfMatcher< Attr > attr
const AstTypeMatcher< RecordType > recordType
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
constexpr ShaderStage getStageFromEnvironment(const llvm::Triple::EnvironmentType &E)
bool randomizeStructureLayout(const ASTContext &Context, RecordDecl *RD, llvm::SmallVectorImpl< Decl * > &FinalOrdering)
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
bool FTIHasNonVoidParameters(const DeclaratorChunk::FunctionTypeInfo &FTI)
TypeSpecifierType
Specifies the kind of type.
bool isa(CodeGen::Address addr)
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
@ OR_Deleted
Succeeded, but refers to a deleted function.
@ OR_Success
Overload resolution succeeded.
@ OR_Ambiguous
Ambiguous candidates found.
@ OR_No_Viable_Function
No viable function found.
@ GVA_AvailableExternally
DeclContext * getLambdaAwareParentOfDeclContext(DeclContext *DC)
raw_ostream & operator<<(raw_ostream &OS, const Value &Val)
ConstexprSpecKind
Define the kind of constexpr specifier.
InClassInitStyle
In-class initialization styles for non-static data members.
@ ICIS_NoInit
No in-class initializer.
OverloadCandidateDisplayKind
@ OCD_AmbiguousCandidates
Requests that only tied-for-best candidates be shown.
@ OCD_AllCandidates
Requests that all candidates be shown.
@ LCK_ByRef
Capturing by reference.
@ LCK_StarThis
Capturing the *this object by copy.
@ IK_DeductionGuideName
A deduction-guide name (a template-name)
@ IK_ImplicitSelfParam
An implicit 'self' parameter.
@ IK_TemplateId
A template-id, e.g., f<int>.
@ IK_ConstructorTemplateId
A constructor named via a template-id.
@ IK_ConstructorName
A constructor name.
@ IK_LiteralOperatorId
A user-defined literal name, e.g., operator "" _i.
@ IK_Identifier
An identifier.
@ IK_DestructorName
A destructor name.
@ IK_OperatorFunctionId
An overloaded operator name, e.g., operator+.
@ IK_ConversionFunctionId
A conversion function name, e.g., operator int.
SmallVector< Attr *, 4 > AttrVec
AttrVec - A vector of Attr, which is how they are stored on the AST.
bool DeclAttrsMatchCUDAMode(const LangOptions &LangOpts, Decl *D)
LanguageLinkage
Describes the different kinds of language linkage (C++ [dcl.link]) that an entity may have.
StorageClass
Storage classes.
ThreadStorageClassSpecifier
Thread storage-class-specifier.
@ TSCS_thread_local
C++11 thread_local.
@ TSCS__Thread_local
C11 _Thread_local.
@ TSCS___thread
GNU __thread.
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword.
MutableArrayRef< Expr * > MultiExprArg
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
@ InternalLinkage
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
@ ModuleLinkage
Module linkage, which indicates that the entity can be referred to from other translation units withi...
@ ExternalLinkage
External linkage, which indicates that the entity can be referred to from other translation units.
@ C
Languages that the frontend can parse and compile.
TemplateDecl * getAsTypeTemplateDecl(Decl *D)
bool isLambdaCallOperator(const CXXMethodDecl *MD)
@ Parameter
The parameter type of a method or function.
@ Result
The result type of a method or function.
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
bool supportsVariadicCall(CallingConv CC)
Checks whether the given calling convention supports variadic calls.
LLVM_READONLY bool isWhitespace(unsigned char c)
Return true if this character is horizontal or vertical ASCII whitespace: ' ', '\t',...
bool isDiscardableGVALinkage(GVALinkage L)
LangAS
Defines the address space values used by the address space qualifier of QualType.
@ TU_Complete
The translation unit is a complete translation unit.
int hasAttribute(AttributeCommonInfo::Syntax Syntax, const IdentifierInfo *Scope, const IdentifierInfo *Attr, const TargetInfo &Target, const LangOptions &LangOpts)
Return the version number associated with the attribute if we recognize and implement the attribute s...
@ TNK_Type_template
The name refers to a template whose specialization produces a type.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
U cast(CodeGen::Address addr)
@ None
The alignment was not explicit in code.
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
@ EST_None
no exception specification
@ EST_BasicNoexcept
noexcept
Visibility
Describes the different kinds of visibility that a declaration may have.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD)
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
void setLoc(SourceLocation L)
setLoc - Sets the main location of the declaration name.
void setCXXLiteralOperatorNameLoc(SourceLocation Loc)
setCXXLiteralOperatorNameLoc - Sets the location of the literal operator name (not the operator keywo...
void setNamedTypeInfo(TypeSourceInfo *TInfo)
setNamedTypeInfo - Sets the source type info associated to the name.
void setCXXOperatorNameRange(SourceRange R)
setCXXOperatorNameRange - Sets the range of the operator name (without the operator keyword).
SourceRange getCXXOperatorNameRange() const
getCXXOperatorNameRange - Gets the range of the operator name (without the operator keyword).
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
SourceLocation getConstQualifierLoc() const
Retrieve the location of the 'const' qualifier.
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
ArrayRef< NamedDecl * > getDeclsInPrototype() const
Get the non-parameter decls defined within this function prototype.
SourceLocation getRParenLoc() const
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
unsigned hasPrototype
hasPrototype - This is true if the function had at least one typed parameter.
One instance of this struct is used for each type in a declarator that is parsed.
enum clang::DeclaratorChunk::@210 Kind
const ParsedAttributesView & getAttrs() const
If there are attributes applied to this declaratorchunk, return them.
static DeclaratorChunk getFunction(bool HasProto, bool IsAmbiguous, SourceLocation LParenLoc, ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, SourceLocation MutableLoc, ExceptionSpecificationType ESpecType, SourceRange ESpecRange, ParsedType *Exceptions, SourceRange *ExceptionRanges, unsigned NumExceptions, Expr *NoexceptExpr, CachedTokens *ExceptionSpecTokens, ArrayRef< NamedDecl * > DeclsInPrototype, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult(), SourceLocation TrailingReturnTypeLoc=SourceLocation(), DeclSpec *MethodQualifiers=nullptr)
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
MemberPointerTypeInfo Mem
static DeclaratorChunk getReference(unsigned TypeQuals, SourceLocation Loc, bool lvalue)
Return a DeclaratorChunk for a reference.
EvalResult is a struct with detailed info about an evaluated expression.
Extra information about a function prototype.
ExtProtoInfo withExceptionSpec(const ExceptionSpecInfo &ESI)
Contains information gathered from parsing the contents of TargetAttr.
std::vector< std::string > Features
Describes how types, statements, expressions, and declarations should be printed.
SourceLocation PragmaLocation
Information about a template-id annotation token.
unsigned NumArgs
NumArgs - The number of template arguments.
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
SourceLocation LAngleLoc
The location of the '<' before the template argument list.